rocky050371
asked on
Memory Stream
I am saving a file in the database, I need to be able to allow the user to edit the file then save it back away.
I also need to know how to launch a file from a memory stream
This allows the user to save the memory file to a location, I really need an edit option
Using ms = New MemoryStream(_document.Mer geDocument , False)
Using fs = File.Open(String.Format("{ 0){1}", Path.GetTempPath, uteFilename.Text), FileMode.Create, FileAccess.Write)
ms.WriteTo(fs)
End Using
End Using
I also need to know how to launch a file from a memory stream
This allows the user to save the memory file to a location, I really need an edit option
Using ms = New MemoryStream(_document.Mer
Using fs = File.Open(String.Format("{
ms.WriteTo(fs)
End Using
End Using
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And if you want to allow a third party program such as MS Word to modify the file and save it back then you would need to do some work. Word can not open the file from memory stream within your program. You would need to save the file to disk, launch the program, monitor it, and when program closes, see if changes have been made and update the file in DB.
To be a little more clear I think:
Private Sub Test()
EditMyFile("Hi.doc", MyFileByteArray)
End Sub
Based in your example, maybe you can use the EditMyFile method in this way:
Private Sub Test()
EditMyFile(uteFilename.Text, _document.MergeDocument)
End Sub
As far as "to launch a file from a memory stream," if you mean you have an executable in the MemoryStream (i.e. binary data), you could write the data out to a temporary file and then use Process.Start to execute it. There are probably ways to execute without writing out to a file, but IMO this would be the simplest way to execute.