Real Software Forums
http://forums.realsoftware.com/

GetSaveFolderItem Problem?
http://forums.realsoftware.com/viewtopic.php?f=23&t=47774
Page 1 of 1

Author:  p0wn3d [ Fri May 03, 2013 6:36 am ]
Post subject:  GetSaveFolderItem Problem?

From the examples in the LR I am doing this on a button click. But getting error "GetSaveFolderItem - this item does not exist)

Dim f As FolderItem
Dim fileStream as TextOutputStream
f=GetSaveFolderItem(FileTypes1.Text,"My Info")
If f <> Nil then
fileStream=TextOutputStream.Create(f)
fileStream.WriteLine namefield.text
fileStream.WriteLine addressfield.text
fileStream.WriteLine phonefield.text
fileStream.Close
End if


I have added a Filetype set to the project. Either I have missed something or I am going mad :evil:

Thanks

Author:  Jason_Adams [ Fri May 03, 2013 8:07 am ]
Post subject:  Re: GetSaveFolderItem Problem?

You can't retrieve a folderitem from the user's browser. This simply can't be done.

In order to "save" something to a browser, you create the file on the server, then use a WebFile and set WebFile.ForceDownload to true. Be sure to use the WebSession.Identifier somewhere (usually a directory to create the file in), so that you don't accidentally overlap multiple sessions doing the same thing.

Hope this helps. :)

Author:  p0wn3d [ Fri May 03, 2013 8:41 am ]
Post subject:  Re: GetSaveFolderItem Problem?

:wink: Thanks Jason

Basically what I trying to do is. I have a Textarea on a webpage along with a button. When the user clicks the button I somehow grab the text content from the Texarea control and prompt the user to save it as a text file on their local PC.

Author:  Jason_Adams [ Fri May 03, 2013 9:02 am ]
Post subject:  Re: GetSaveFolderItem Problem?

There's an example just like this in the LR: http://docs.realsoftware.com/index.php/WebFile.Data

Just change "Hello World!" to the contents of your text area. :)

Author:  p0wn3d [ Fri May 03, 2013 9:15 am ]
Post subject:  Re: GetSaveFolderItem Problem?

:wink: Thanks Jason got it now from the example...

TextFile = New WebFile // TextFile is a property of the web page
TextFile.MimeType = "text/plain"
TextFile.ForceDownload = True // If False, the browser may try to display the file instead of download it
TextFile.FileName = "TextFile.txt"
TextFile.Data = "Hello, world!"
ShowURL(TextFile.URL) // This causes the file to be downloaded


I wish the LR would be a little more friendly at times. IE: In this case "You need to create a new Property
textfile As Webfile' :lol:

Author:  Jason_Adams [ Fri May 03, 2013 9:31 am ]
Post subject:  Re: GetSaveFolderItem Problem?

I encourage you to sift through the examples, too, as that is pretty well organized. I've learned quite a bit over the years from glancing through those. And there is a /Web/Downloading/Downloading.rbp example that goes over this. ;)

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/