Question

I have a C# application setup as a remote app running on a server.

When the application runs I grab the MyDocuments folder from System.Environment in order to save down user generated files. The path for MyDocuments that I get back is naturally the one on the server.

Is there a way to get the MyDocuments folder path of the client machine instead? Or at least some way to get the name (or IP) of the machine that invoked the remote app?

Was it helpful?

Solution

Found a solution.

The client machine can be accessed using \tsclient\\...

I first default the MyDocuments path in my application to Environment.SpecialFolder.MyDocuments which is of course the machine that the "server" of the remote app. Then I check for the existence and write access level of the following folders on the client machine

\\tsclient\C\Users\<username>\Documents
\\tsclient\C\Users\<domainname>.<username>\Documents
\\tsclient\D\Users\<username>\Documents
\\tsclient\D\Users\<domainname>.<username>\Documents

and then for XP...

\\tsclient\C\Documents and Settings\<username>\Documents
\\tsclient\D\Documents and Settings\<username>\Documents

If none of those exist then I use the folder on the "server" of the remote app.

Not the most elegant, but it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top