[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
Re: Simple - Create txt file
IO.File.CreateText("c:\myfile.txt")
From Documentation on IO.File.CreateText:
Quote:
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:
Quote:
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...
Re: Simple - Create txt file