C# connection and file access question

  • Thread starter Thread starter Jason Huang
  • Start date Start date
J

Jason Huang

Hi,

In C# the SqlConnection=
"data source=192.168.100.100;uid=MyID;password=MyPwd;database=ETCserviceTest
";
and it is for SQL data connection.
Do we have some similiar method for accessing files in a paticular Windows
XP machine?
Thanks for help.


Jason
 
The windows file system allows file sharing under the control of the
machine's owner. Windows XP does not normally allow external access to the
files on that machine.

However, file sharing is enabled, and if you have permissions to the machine
(in other words, if you are listed in the Local Users or Local
Administrators group on that machine) then you can access files on the C
drive as:
"\\MachineName\C$\mydirectory\myfile" using normal methods for opening,
reading, and writing files (instead of SQL connect strings).

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Thanks Nick.
But is it possible for using the C# code to get into the Windows XP folders
and access the files? given that we know the Account and Password?
Thanks for help.


Jason
 
Yes, assuming that the machine you are accessing the files FROM is on the
same domain as the machine with the files. If this is so, then impersonate
the user that has permissions, and simply open the file using the UNC
notation in the prior response.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

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

Back
Top