Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Changing Read Only Files?


Hi,

How do you go about changing a read-only file so it can be written to through VB? I'm making a program where I don't want the files to be easily changed by the user while it's not running, but that the program can edit during runtime.

The best way I can describe this is a file which has something like this in it:

WorkingDirectory=C:MyVBProgramWorking

I want the file to have a read-only attribute, so no one can change it when my program isn't running. But I'd like to be able to have the program change the attribute on the file and edit it.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Changing And Email Multi Files, And Changing The File Name!
Hey everyone,

Ok, this is my problem. What i need to do is create a new program that will when ran open up a txt document. Once the txt document is opened it will then compaire the date of the txt document to the current date. If the txt date is 7 days less then the current the date will be updated in the txt document. That is the easy part and i have that done. Now what i need is once the document is check and the date is 7 days less, i also need to open a different txt file save it as Log(current date) and then e-mail it off. If you could provide any information at all that would be great. Below i have my code and comments where i think things would go but feel free to change stuff around. Right now i am open to all ideas.

Code:

Option Explicit

Sub main()

    Dim logDate As Date
    Dim curDate As Date
    ' This is the variable in which to put the date from the text file.
    Dim TheDate As String

    ' Open the text file. For input (read-only) access. You will, of course, have to supply the correct filename.
    Open "log.txt" For Input As #1

    ' Grab the first line in the file, which holds the date - use a string variable for this
    Line Input #1, TheDate
    ' Close the file
    Close #1

    'convert TheDate string variable into logDate datetime variable
    logDate = CDate(TheDate)

    ' Subtract 7 days from the current time (DateAdd), and check the returned value with the date from the text file to see which one is closer to the current date.
    ' Dates can be compared like regular numbers. 1/1/2004 is LESS than 1/5/2004
    curDate = Now - 7
    MsgBox curDate
    If curDate >= logDate Then

        ' If we get here, then the date in the textfile is older than 7 days. Write out the current date to the text file.

        ' Open the text file for Output (write-access)
        Open "log.txt" For Output As #1

        ' Dump the date portion of the current system time to the file
        Print #1, DateValue(Now)

        ' Close the file
        Close #1

        'open the second txt file here and save it as Log(current date)
        
        'and email it to my email
        

    Else

        MsgBox "It has not been one week yet."
                

    End If
End Sub



Well there is all my code and i thank you in advance for all you help that i have gotten before. This is my biggest challenge yet but with you help i am sure i can get threw it. Thanks again

-Rekuyki

When I Make A (install) CD-Rom All Attributs Files Changed To Read Only Why? Read Only
I would like to my attributs files look the same after the installation. But when I create the cd all the files took the properties read only.

And in my programme,I need to write in some files.

Who can help me ?

Sorry for my bad english.

Redg
Thanks a lot.

Changing Read Only Properties
I am trying to change the read only properties on a file though VB. Can this be done and if so how?

Thanks for your help

Changing A Textbox Into A Textarea, Read!
hi there,

I have a textbox I want to create into a textarea by assigning a scrollbar to the textbox. I know this can be done but dont know how to do it.


Does n e 1 know?????

Changing A File Property So Its NOT Read Only
heya guys

if i copy a file off a cd using code it leaves the file as read only. how can i change it from read only to normal file status?

thank you in advanced

frosty

Simple Question - Please Read! About Changing Case
hi,
got a database in VB
when the use types in their name, eg. 'Paul' i want to make sure their name has a capital letter.
ie if they type in 'paul' i want it to take a lool at the string, and if the first letter is in lower case, automatically change it

ie type in 'Paul' - its fine
type in 'paul' gets changed to 'Paul'

any help??

Changing The Read Only Property BorderStyle During Runtime
After 8 years experience in VB, I still don't know how to change the Borderstyle property of a Form during runtime, which is a read only property that can only be changed during design time. I can do it using Win32 to create my own window, which in return allows me to have full control over the window and all, but there's gotta be a way to do it on a regular form. API's might be the solution.

The reason I need it is because I'm making a OpenGL tutorial with a hybrid initialization of both Fullscreen and Windowed mode, which you can choose simply by a boolean variable to go to either or. Only thing is though is that the border is there during fullscreen mode. I solved it using DirectX8 to switch to fullscreen mode, then using OpenGL for rendering, which eliminated the border for me, but I would like to avoid using DirectX to solve that problem so I can use strictly OpenGL. Does anyone know how to change the Borderstyle of a form during runtime?

Changing The Colours In An RTF Text Box. (STILL UNRESOLVED, PLEASE READ)
Hi.

How DO you change the colours in an RTF text box? I know how to change the colour for the whole text, but I want to search the incoming text for certain codes which tell it what colour to make the text, but no-one seems to know how to do it. For more info and a slightly clearer description, click here to see the thread which this started as.

Thanks.

Read PDF Files / Extract Data From PDF Files
I wondering IF it's possible to read data from pdf files?

This because I would like to write a sub for pdf files like below:

Code:

Text = ReadWordDocument("C:TempTest.doc")

Public Function ReadWordDocument(strFileName As String) As String

Set oWordApp = CreateObject("Word.Application")
If oWordApp Is Nothing Then Exit Function

Set oWordDoc = oWordApp.Documents.Open(strFileName)

oWordApp.Selection.WholeStory
ReadWordDocument = oWordApp.Selection.Text

oWordApp.Quit

Set oWordDoc = Nothing
Set oWordApp = Nothing

End Function

Changing .exe Files
Hi, I'm just wondering how you would change a .exe with notepad or a hex editor without making it stop working

If I open a .exe file and save it (without anything changed) it will cease to function

My guess is that .exe files do some math with the last modified date and the contents of itself to make a checksum type thing at the end of the file. Am I right? So if I were able to stop the computer clock so that the modified date/time would be the same as before, the assembled program should keep functioning.

How would I change .exe so they would continue to work then? I have tried to stop the computer clock but it didn't work. It just keep running in the background. Any ideas?


Thanks!!

Windows Error 015: Unable to exit Windows. Try the door.

Changing Files
I have a screen capturer. When the user presses a key it captures the screen. Then it saves the picture into a file. How do i make it that if there's an image called cap1, it will save the image as cap2, or cap3 etc. Help please!

--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: christopherfolger@hotmail.com
for the address

Changing The Icons Of Files.
Hello

I am searching a way to change the icon files of different files liek .txt or .html but I can't get it. Can soembody help me with it.

Godlord

Changing Class Files
I have the following code. Is there anyway of combinning the code in customer.cls into customeraccount.cls so I only have 1 class file? Have I repeated myself or do I need them both?

FORM1

Code:
Private Sub cmdCreateAccount_Click()
Dim newAccount As New customerAccount

customerName = InputBox("Please Enter Customer Name")

If IsNumeric(customerName) Or customerName = "" Then
MsgBox "Please Check And Enter Correct Name", 16, "Error Message"
Else
Set account = newAccount
AccountCollection.add account
account.customer = customerName
End Sub

customeraccount.cls

Code:
Private accountCustomer As New customer
Public Property Get customer() As String
customer = accountCustomer.customerName
End Property
Public Property Let customer(ByVal newcustomerName As String)
accountCustomer.customerName = newcustomerName
End Property

customer.cls

Code:
Private mycustomerName As String
Public Property Get customerName() As String
customerName = mycustomerName
End Property
Public Property Let customerName(ByVal newcustomerName As String)
mycustomerName = newcustomerName
End Property

Changing Text In RTF Files
I would like to locate and change (to upper case) the text that falls between brackets ([]) in the RTF data for a richtextbox. Why is that SelRTF in the highlighted code doesn't contain the expected selected text?


VB Code:
intStartPos = -1    With rtbMessage        Do Until intStartPos = 0            intStartPos = 1            intStartPos = InStr(intStartPos, .TextRTF, "[")            If intStartPos > 0 Then                .SelStart = intStartPos                intEndPos = InStr(intStartPos, .TextRTF, "]")                .SelLength = intEndPos - intStartPos                [hl="#FFFF80"].SelRTF [/hl]= UCase(.SelRTF) '.SetText doesn't work either            End If        Loop    End With

My Files Are Changing Themselves! No Logic!
I'm doing a part of my coursework for my A-level (I know compter course donesn't make me a programmer) and I've hit a problem.

But I cant work it out, something has gone wrong. let me show you.


VB Code:
Open App.Path & "TurkeyList.dat" For Random As #1 Len = 28          Dim RecordNumber As Integer     RecordNumber = 0          Do      RecordNumber = RecordNumber + 1      TurkeyList(RecordNumber).TurkeyID = RecordNumber        Dim Weight As Integer        Randomize        Weight = Int((5000 * Rnd) + 5001)       TurkeyList(RecordNumber).TurkeyWeight = Weight       TurkeyList(RecordNumber).TurkeySold = False       TurkeyList(RecordNumber).TurkeyCustomer = "                                                "       TurkeyList(RecordNumber).TurkeyOrder = 0      Put #1, RecordNumber, TurkeyList(RecordNumber)     Loop Until RecordNumber = 40


Thier you can see that I've just made 40 records with all the information they need.

just have a look at this bit again


VB Code:
TurkeyList(RecordNumber).TurkeySold = False


As you can see I've just set that to false, you can see it!

And then when I open the form this happens for all the combo-boxes


VB Code:
cboTurkey1.ClearGet #1, 1, TurkeyList(1)  cboTurkey1.AddItem "ID: " & TurkeyList(1).TurkeyID  cboTurkey1.AddItem "Weight: " & TurkeyList(1).TurkeyWeight & " Grams"If TurkeyList(1).TurkeySold = False Then    cboTurkey1.AddItem "Turkey not sold"  Else    cboTurkey1.AddItem "Turkey Sold"    cboTurkey1.AddItem "Sold to " & TurkeyList(1).TurkeyCustomer    cboTurkey1.AddItem "Order # " & TurkeyList(1).TurkeyOrderEnd If


And as you can see


VB Code:
If TurkeyList(1).TurkeySold = False Then    cboTurkey1.AddItem "Turkey not sold"


so in all logic cboTurkey1 would have this item added to it "Turkey not sold"

You can see that it should, I've just written the file!!!!

But no, when i open the form things like this happen



Now how does that make sence, The wieght is now the ID, the ID is now the wieght, TurkeySold = False happens to mean TurkeySold = True!!!!


Can someone please help me work it out, I've had 2 differnt people look at this and they can't work it out, mabey you can.



Stupid computers with thier stupid binary! GRRR

PS I've attached teh file so if you want you can have a look at it.

Changing Names Of Files
take a look at this code


VB Code:
Public Sub Form_Load()   FF = FreeFile    Open App.Path & "CBNames.txt" For Output As #FF  gg = FreeFile    Open App.Path & "CBports.txt" For Output As #ggEnd Sub


as u can see i m initializing two files which have names as " CBNames.txt" and "CBports.txt"

now come to what i want to do .. assume i have prompted user to enter his name in inputbox and declared that as string .. let it be "name"
for a time being
i have value of name = jhon as it is string
now i want to initilize somehow
that "CBNames.txt" has a name of "jhon1.txt"
and "CBports.txt" has a name of "jhon2.txt"

inshort i want to set the file names depending on string input from user ...

Changing Permissions On Files
A VB app I wrote creates text files that need to be shared by several network users. I do I change the permission on the file so that they become available to EVERYONE. It is a Win 2000 environment.

Changing Extension Of Files
Please help!
How can I rename a lot of file extension?
For example : I want to change all .jpg to .001


thanx

Wav Files Changing... Viewing..
How do i change , make , and view file info on wav files. like artist, title, track(Name), or any other property ? using a vb app

Changing The Date Of Files
How can I change from VB the date of files? I Have to distribute an app with your .exe, .rpt and .mdb with the same date.

Thanks

------------------

Working With Changing Text Files.
Quick background:

There is this game that outputs alot of otherwise unaccessable information to a debug.log file, it's just a simple text file that can be viewed even in the ever complex notepad. The file is added (appended, whatever) to as the game runs. After the game is done the file is still intact, but will be completly erased and will start fresh next time the program is run.

What I want to create is a program that will run in the background and check the file and parse (seperate, not sure if that term is proper?) out useful information that I can do as I please with. More specificly, I want to create a program that will keep statistics on the players and what they do.

I'm shaky on file access, or I could probably figure it out on my own. I will figure out something, but I hoped someone could point me to a quick solution.

What I'm thinking is simply watch the file and the line count (can you do this?) and process any new lines that are added to the end (appended).

A 2nd method (maybe more complex?): Watch and see when the program that adds to the debug.log file stops running, then have the program process the whole thing in one swipe and be done.

Just want a few tips. Thanks.

PS - Sorry if this has been asked. I tried a few searches, but I may choose different wording that what the other person who asked the same thing used.

Changing Languages On-the-fly With Resource Files
Hi everybody,

I've done a search and found few threads that were somewhat related to my question but I think I still need to try and get more ideas and suggestions...

If I have a resource file with say English and Spanish string tables, is it possible to change languages in my VB program on-the-fly without having to change the Regional Settings under the Windows setup?

In other words, is there any way to access the Spanish string table entries in my resource file even though the Windows Regional Setting is set to English?

For example, on the main form of my program, I might have a button that says English, and another one that says Spanish. The user would click either button to select the language to be used within my program, irrespective of the regional settings.

Thanks in advance.

Opening Over 100 Files And Changing Certain Text?
I was wondering if its possible to make a program that'll open every file thats in a folder (file type is htm) and changing certain text in it? Also if it would be possible to changing some code in the file that is multi lined?

Changing A Files Permission On Machine
Is there a simple script that would change a files permission to read-only, like a .dat to read only? any help or point in right direction if you don't know?

Music - Changing Keys??CD+G Files?? PLEASE HELP..
Hi, i was wondering if anyone knew how i can change the key of a audio file? the file is a CD+G file. Im very sure its a .wav file and grahics = CD+G..this is the format they use for Karaoke. I am trying to make a program that can lower or raise the key of the audio without slowing down or raising the tempo. Is this posible with API or just VB code? What type of code? Please help if you can. Also, to do this, does it mean i need to take out the .wav and minipulate that, then reassemble it? I'd rather not do that just apply the change to the wav with out disassembly. If you'd like to contact me on AIM to help my screenname is: dmg2006

Thank you.. - Dean

Changing Pics In Resource Files?
Is there anyway to change images in resource executible files?

Through vb of course

Changing Default Program To My Own For *.mp3 Files
How do i make a program that i made be the default program to open mp3 filez. I need to do this in code, not in folder options.

Changing Excel Files - Easy?
Howdy!

I want to update a test.xls file. I can open Excel97 and open the file I want, but how do you set the Sheet and add values per cell using vb6.

here's what I have so far

Dim MyXL As Object
Dim ExcelWasNotRunning As Boolean

Set MyXL = GetObject(, "Excel.Application")
if Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear

Set MyXL = GetObject("C: est.xls")
MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True

For example I want to add "hello" to cell B13

If you can help, Thanx

Changing Parts Of A Text Files
Hi Gents,
I need some help editing text files. Im a newbie in VB, but having fun so far. Anyways, I wrote a small program that extract text files then show it in a TEXTBOX names caldata. Like so

Extracted Data - Printed on a Text box
-----------------------------------------------
[Mill1]
PosX = -100.626
PosY = -134.928
PosZ = -31.508
RunF = XYZ
RunV = 1.800

[Mill2]
PosX = -100.539
PosY = -34.877
PosZ = -31.522
RunF = XYZ
RunV = 1.800
----------------------------------------------
Now, I need to extract the value of PosZ in mill1 and Mill2 then add 250(for example). Then replace the old values PosZ with the new values in the TEXTBOX.
I dont even know where to begin. Any ideas?


Music - Changing Keys?? CD+G Files? HELP PLEASE..
Hi, i was wondering if anyone knew how i can change the key of a audio file? the file is a CD+G file. Im very sure its a .wav file and grahics = CD+G..this is the format they use for Karaoke. I am trying to make a program that can lower or raise the key of the audio without slowing down or raising the tempo. Is this posible with API or just VB code? What type of code? Please help if you can. Also, to do this, does it mean i need to take out the .wav and minipulate that, then reassemble it? I'd rather not do that just apply the change to the wav with out disassembly. If you'd like to contact me on AIM to help my screenname is: dmg2006

Thank you.. - Dean

Changing The Attributes Of Multiple Files Using *.* ?
I have a program which copies certain directories to CDROM. Everything works fine apart from all the files' attributes get changed to "Read Only".
When the files are then imported into another computer the files remain as "Read Only".
I have then been trying to use the SetAttr function to convert those directories back to "Normal".
I have been using *.* wildcards as the filenames are always different, but I cannot get them to work.
Could anybody tell me how to change the attributes of multiple files using a wildcard.

Many thanks in advance

Regards
Colin Macandrew

Changing Icons Of Text Files
I know how to change the Icon of a Shortcut but can not find any way to change the Icon of other files such as a text file.
Anyone out there know how to do this? I have searched my favorite haunts with no success.

Thanks,

John G

Read Files By Using Get #
I'm trying to get this method to work, but I'm pretty sure that a made a lot of fauls.
Can anyone please correct this sub?


Code:
Private Sub Command1_Click()
Dim Buffer() As Byte
OpenedFile = FreeFile

Open "C:file.txt" For Binary Access Read As #OpenedFile
ReDim Buffer(1 To 4096) As Byte

Do While Not EOF(OpenedFile)
Get #OpenedFile, 4096, Buffer()
DoEvents
Loop
Close #OpenedFile

Text1.Text = Buffer
End Sub

Read Only Files
I have two problems, first is opening a word document in a VB form and not as an Word application and another is opening this file in read-only format...please help...thanks!

Zip Files (read Them)
Does anyone know if it's possible to open up a .zip file, read it like if it was a .txt file, and add it to a text box. Then put it back in a new file and add a zip extension and it would still work with winzip etc....

Read Only Files...
Ok, for a game, i want im saving all the stats of the user and game stuff into a text file. Is there a way to make this file read only? Like, certin windows files wont let you delete them, nor edit the data inside them. Is there a registry path i can add or something to add this file to that list?

VB6 Won't Read My Mdb Files
my VB won't read my MDB databases but will let me open databases saved in an older version of access. is there anyway of making the newer databases i save compatible
or is there any solution for this?

thanks
ScOrP

I Don't Read DAT Files
Hi everyone

I have a problem

i want the data in DAT files but i dont

DAT.zip attach in existence OCAK08.DAT - dbFiles.xls - FIS.DEF files
OCAK08.dat = Database file
dbFiles.xls = DAT file transfer to XLS (XLS file my accounting software transfer modül receipt)
FIS.DEF = DAT file in existence Field name and character digit.

my accounting software writen MSDOS C compiler

what i want

i want to read dat file in VB 6 according as dbFiles.xls

how can i do.
Please help me

How To Read Pdf Files
hello
i have 40 PDF files... how can i read text from it one by one....?
ram

Can Vb6 Read TGA Files
Hi All,
Just wondering if anyone has developed a Vb6 application that was able to read TGA files?

Read-only Files
How do I change a file property from within VB? For instance I want to open a MSWord document from a VB application and I want to make it Read-Only in some instances but full Read-Write in other instances. The choice will be made via a message box perhaps.

A Way To Read Pdf Files In VB
Anyone seen an examples of how to read a pdf file using good old VB? The adobe site just has a 600 page pdf document on the topic but i dont have 16 light years to read it.

REad All Files On CD
How can i read all the files on the cd with lot's of directory nested?

How can I get the filename,filesize, directory path? What is the fastest approach?

thanks

Have My App Read VB Files (frm, Bas)
How can I have my app open a specified vb file?? I have a common dialog which will get the the path of say, a module (*.bas), how can my app fill a text box with the code from that module? and can this be done with frm, cls etc etc...

Read-Only Files
Hello,
I made a CD of my works to transfer them to my other computer, but it happen then all the files was writen as Read Only. Since the number of files is important, I do not want to change this attibute for all my file. I was wondering if it was possible to change the read only attribute using VB?

Thanks for help.

How To READ From Files?
Hello, everyone... Well. I have a question about how to SET A FILE's STRING to a CoMMAND


Like in MSAGENT CONTROL.
MSAGENT1.characters("Bot").Commands.add "this","this","this",,False



Instead I want to read the stuff from a file that contains commands... How do I do that?

LIKE THIS???:

Open App.Path & " ext.txt" For Input As #1
Dim thecmd As String
Do Until EOF(cmdfilenum)
thecmd = Input$(LOF(1), #1)

Loop
Close #1
MSAGENT1.Characters("Bot").Commands.add thecmd




Is that right???

Read PDF Files
Is there an easy way to load pdf files into a text box.

PS: thanks for the help you guys/gals have been great!!!

How To Read From Files?
Hi..i am new here..
Currently i am doing my final semester project which requires to display characters on dot matrix array. I am going to use VB as my interfacing software.
I am a newbie to all VB stuff...hehe..hope you dont mind.

My project requires to read words from textfile (eg. notepad) and send them out to the serial port.

Thanks!!

Read DBX Files
Hi there!

Is there any way that I can read a DBX file...get the message from it also with the file attachements? would like to create a software just like thw MailNavigator software... My purpose for this is to avoid licensing....

Pleae Help

Regards,
Ian

Copyright © 2005-08 www.BigResource.com, All rights reserved