Not sure what I’m doing wrong. Trying to make a series of folders and text files on a network share, based on fields the user will fill in.
Making the folders was easy, but when using textstream to create the text file, Im getting NilObjectException errors. I’ve done this in the past with SpecialFolders, but I can’t seem how to get it to work with paths that are strings. The variable “Path” in this snippet is a network URL I have defined earlier.
dim DOC_PATH as string
DOC_PATH =path + "\\2_Doc"
Dim DN As FolderItem
DN = GetFolderItem(DOC_PATH +"\\Deployment_notes.txt")
Dim t as TextOutputStream
t = TextOutputStream.Append(DN)
t.Writeline(DEPLOYMENT_TEXTAREA.text)
t.Close
ioexception means more like that your path isnt referring to the file the in way you think
like “this file does not exist”
but I can debug that from here
you will have to put in a break point in there & see why that might be happening
DN’s properties for exists etc are all true ?
An IOException could result from not having permissions
but you’d have to look in the IOException object to know if there is any such message or error code
All of the folder paths are there…they are always created prior to this portion of the code.
Not sure why this is so stubborn. Here is the same thing from a program I wrote a file back. It uses special folders, and works flawlessly.
[code] Dim Documents As FolderItem = SpecialFolder.Temporary.child(“AutoIT Maker”)
Dim f As FolderItem = Documents.Child(“Untitled.au3”)
Dim t as TextOutputStream
If f <> Nil then
f.delete
t = TextOutputStream.Append(f)
t.Writeline(MAIN.SCRIPT_TEXTAREA.text)
t.Close
end[/code]
So I basically am trying to use the equivalent with a shell path.
You forgot to Create the TextOutputStream?
Or open if if already exists and want to append to
dim DOC_PATH as string
DOC_PATH =path + "\\2_Doc"
Dim DN As FolderItem
DN = GetFolderItem(DOC_PATH +"\\Deployment_notes.txt")
Dim t as TextOutputStream
t = TextOutputStream.Open(DN)
t.Writeline(DEPLOYMENT_TEXTAREA.text)
t.Close
TextOutputStream .Open(Folderitem)
Will create the file if it does not exists
TextOutputStream.Append(DN) (Api1.0) should do that same thing as .Open(DN) does (API2.0)
Not sure why it doesn’t work, perhaps the Network drive is busy or inaccessible ?
GetFolderItem(path As String, Optional pathMode As Integer) As FolderItem
PathMode to something that works
or try
dim DOC_PATH as string
Dim DN As FolderItem
#If targetWindows
DOC_PATH =path + "\\2_Doc"
DOC_PATH = DOC_PATH.ReplaceAll("\","/")
DN = GetFolderItem(DOC_PATH +"/Deployment_notes.txt")
#else
DOC_PATH =path + "\\2_Doc"
DN = GetFolderItem(DOC_PATH +"\\Deployment_notes.txt")
#endif
Dim t as TextOutputStream
t = TextOutputStream.Append(DN)
t.Writeline(DEPLOYMENT_TEXTAREA.text)
t.Close
That’s odd, did you try to set the pathMode ?
can you copy and paste the Exact string that is ending up in DN, that is the DOC_PATH variable.
Also try to paste that exact string (resulting from debugger) into the windows explorer filepath bar. You’ll see if it points to the right direction.