Can't resolve FolderItems and Native Path

Try

dim DOC_PATH as string
DOC_PATH =path + "\\2_Doc" 
Dim DN As FolderItem
dim s as string = DOC_PATH +"\\Deployment_notes.txt"
break

What is the value of s? Is it a valid path? Or is it malformed? If DN is nil, then it’s likely that the path is bad.

DN is nil. The “Deployment_notes.txt” doesn’t exist yet. I’m wanting it created along with the text in the TextArea.

This has never been an issue when using SpecialFolder.

Just for grins…I added a file called “Deployment_notes.txt” in that directory.

Same thing. DN is nil. S looks good.

If the path is good, DN should not be nil. Are there any special characters in the path, or spaces?

What about

dim DN as FolderItem
DN = GetFolderItem(path)
DN = DN.child("2_doc")
DN = DN.child("Deployment_notes.txt")

Do you get a non-nil DN? If not, which line fails?

To take another tack, you say that the folder is being created. Can you pass that folderitem into this code and use it just like you would user specialfolder? Also, what does the code look like that creates the folder on the network share?

  1. Restart reading the LR for TextOutputStream TextOutputStream , especially where ) in the example - there are On Try …/… Catch / End Catch…

  2. While you are restarting, do that on your local Hard Disk (day in the Documents folder) and be sure it works there.

  3. Once it all works fine, you are ready to do it on your real project.

BTW: Try / Catch is here to deal with IOException (as you will read in the Example).

Good luck.

[quote=471828:@Tim Hare]If the path is good, DN should not be nil. Are there any special characters in the path, or spaces?

What about

dim DN as FolderItem
DN = GetFolderItem(path)
DN = DN.child("2_doc")
DN = DN.child("Deployment_notes.txt")

Do you get a non-nil DN? If not, which line fails?

To take another tack, you say that the folder is being created. Can you pass that folderitem into this code and use it just like you would user specialfolder? Also, what does the code look like that creates the folder on the network share?[/quote]

DN = DN.child(“2_doc”) fails.

Here’s the whole code. Basically, the user will fill in three fields, which will create the path structure, and then any text they write into the TextArea would be inserted into a newly created “Deployment_notes.txt” at the same time in the “2_doc folder”.

[code] dim VENDOR_NAME as string

VENDOR_NAME =VENDOR_TEXTFIELD.text

dim PRODUCT_NAME as string

PRODUCT_NAME =PRODUCT_TEXTFIELD.text

dim VERSION_NUMBER as string

VERSION_NUMBER=VERSION_TEXTFIELD.text

Dim PATH as String

PATH ="""\\ANDC1WAPP0050.DS.SJHS.COM\source$\software" + VENDOR_NAME + “” + PRODUCT_NAME + “” + VERSION_NUMBER + “”

dim s as new Shell

s.Execute ("mkdir " + path + “\1_Orig_media”)
s.Execute ("mkdir " + path + “\2_Doc”)
s.Execute ("mkdir " + path + “\3_Packaging_work”)
s.Execute ("mkdir " + path + “\4_Deployment”)

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[/code]

Hope that helps.

Why arn’t you creating the folders using FolderItem.CeateAsFolder? Is the shell for a specific reason?

If you keep the shell, make sure s.LastErrorCode = 0

Did you intend for this path to begin with a quote mark? If so, you’ll need to add one after each of the mkdir statements.

[quote=471882:@Derk Jochems]Why arn’t you creating the folders using FolderItem.CeateAsFolder? Is the shell for a specific reason?

If you keep the shell, make sure s.LastErrorCode = 0[/quote]

Well, as you can see from this post, I’m having trouble using FolderItem and LAN paths. Using the shell just worked, so viola.

Yes, as it’s necessary if the user uses spaces in the names in the fields.

Good eye, but interesting, the shell creates the folders without neededing the end quotes, so I didn’t catch it right away.

Nevertheless, adding end quotes to Deployment_notes.txt doesn’t make the problem go away. DN still equals nil.

Fails in what way? Returns Nil? Or throws a NilObjectException?

And you should remove the quote from the beginning of path. That would be an invalid path for GetFolderItem otherwise.

One more thought: Does DN = GetFolderItem("\\\\ANDC1WAPP0050.DS.SJHS.COM") return a valid folderitem?

Ding! Ding! It was the quote at the beginning (necessary to have the shell create a path with spaces properly) that was throwing off GetFolderItem.

It’s working perfectly. Perhaps now I’ll try creating the folders with FolderItem.CeateAsFolder instead of the Shell.

Thank you Tim and everyone else for all of your help!