Process.Start throws Access Denied Win32Exception

G

Guest

I am using System.Diagnostics.Process class to open a word document by call
ing Process.Start("test.doc"). I am using C# as programming language. On some
of the computers on running this code i get "Access is Denied"
Win32Exception. What do i do to not generate this exception ?

Any help highly appreciated,

Thanks,

Jay
 
L

Lau Lei Cheong

Either the user do not have right to access the "test.doc", or does not have
right to start MSWord or whatever assigned to open the "test.doc" (like
WordPad).

Go check whether they can open the file directly first.
 
G

Guest

Thanks Lau,
That is the first thing i did was to check the permissions and
really the permissions are the same, and to confirm the problem
was not related to permissions, I even logged in as a Administrator
and ran the application.

Basically, I am trying to export data to word document, for which i am
taking the following steps.

I have a richtextbox which shows data to user, as and when the user
is happy with the data, he clicks export, so a save as file dialog pops
up and user can give a name to the file and store it where he wants.
Now after he clicks save, and the control returns to our program,
i fire the Process.Start("filename") which the user had assigned.
Now i dont get why this works on 5 / 6 machines and fails only on the
one laptop ! i have checked permisions of each and every folder possible.

Hope this explains my problem, and if possible u might have an idea to solve
it
Thanks,
Jay
 
L

Lau Lei Cheong

Could it be because the file is not completely saved when you run
Process.Start()?

See if it helps to run a loop on File.Open() on the path until it returns a
handle, close the FileStream and use Process.Start() to open it.

Or it'd be neater if just Thread.Sleep() for 2 seconds in between...
 
G

Guest

Thanks for your reply Lau and VJ,

Reflection i think would be too heavy duty to just open a
word file, but may be give it a go and see.

Still have not found a solution for this problem,
but will post it whenever i have any.

Let me know if u guys have any other ideas on the same,

thanks

jay
 
L

Lau Lei Cheong

Strange... it yet looks like a permission problem.(ACL while file copy
follows its parent.)

Would you mind to run "cacls test.doc" on the "Program Files" folder and
paste the output here?

Feel free to mask out the account names, but just let us know which one is
the account your application is running on.
 

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

Top