Start Process from Isolated Storage File

J

JT

Hi,

..NET gurus, if I'm approaching this the wrong way, your suggestions
are welcome.

I am creating an xml file and an xslt and usint those to create an
html file and storing them all in Isolated Storage. I can access them
all as streams, however, I want to be able to open the resulting html
file in a browser in order to print the page. I want to use the
System.Diagnostics.Process to open it, however, the StartInfo.FileName
property expects the name of a file. The IsolatedStorageFileStream
object has a deprecated Handle property and no way to obtain the file
name (and its path). I am assuming that is by design for security
reasons, however this doesn't help me since the Process object can't
accept a Stream object instead of a FileName value.

The reason I want to use Isolated Storage is because I don't want it
to be necessary to create a server side directory for storing the
files I create. Also, I don't want to have to create a unique ID for
each file created for each user.

Secondly, I would like to be able to delete the files afterwards or
have them overwritten each time and (at least in debug mode) it seems
to create a new Isolated Storage directory every time I run the
application. Is that because it's a new assembly every time it's
compiled. I'm creating the IS with IsolatedStorageFile.GetStore
(IsolatedStorageScope.User | IsolatedStorageScope.Domain |
IsolatedStorageScope.Assembly, null, null); If stored on the client
machine, it's okay if the file has the same name every time.

Thanks,

JT
 
I

Igor Brylin

Hi.

I wrote some method, accepting string parameter (isolated file name):

public void StartProcessFromIsolatedStorage(string isolatedFilePath)
{
//System.IO.IsolatedStorage.IsolatedStorageFile isolatedStorageFile = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly();
System.IO.IsolatedStorage.IsolatedStorageFile isolatedStorageFile = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForDomain();

if (!isolatedStorageFile.FileExists(isolatedFilePath))
throw new FileNotFoundException(isolatedFilePath);

Type isolatedStorageType = isolatedStorageFile.GetType();
System.Reflection.PropertyInfo piRootDirectory = isolatedStorageType.GetProperty("RootDirectory", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
string fullPath = System.IO.Path.Combine(piRootDirectory.GetValue(isolatedStorageFile, null).ToString(), isolatedFilePath);
System.Diagnostics.Process.Start(fullPath);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top