|
-
Mar 10th, 2006, 05:38 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Simple - Create txt file
Guys,
How do I create a blank text file if it doesn't exist....
Bob
VB Code:
'Setup CustomDic for C1Spell
Dim CDFile As String
CDFile = CurrentContract.Path & PWBlib.library.DynamicProperty("CustomDicLocation")
If Not IO.File.Exists(CDFile) Then
'IO.FileMode.CreateNew
End If
SpellInitialised = True
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Mar 10th, 2006, 05:44 AM
#2
Re: Simple - Create txt file
IO.File.CreateText("c:\myfile.txt")
From Documentation on IO.File.CreateText:
This method is equivalent to StreamWriter(String, Boolean) with the append parameter set to false. If the file specified by path does not exist, it is created. If the file does exist, its contents are overwritten. Additional threads are permitted to read the file while it is open.
Meaning that you don't have to check if it doesnt exist. If it doesnt exist, it creates it.... if you don't want to overwrite the contents if it exists, just use IO.File.AppendText...
Documentation on IO.File.AppendText:
This method is equivalent to StreamWriter(String, Boolean). If the file specified by path does not exist, it is created. If the file does exist, write operations to the StreamWriter append text to the file. Additional threads are permitted to read the file while it is open.
So with appendtext, you still don't have to check if it exists, and also you won't overwrite the current contents of the file...
Last edited by gigemboy; Mar 10th, 2006 at 05:49 AM.
-
Mar 10th, 2006, 05:50 AM
#3
Thread Starter
Fanatic Member
Re: Simple - Create txt file
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|