469,649 Members | 1,259 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,649 developers. It's quick & easy.

How can I get information of specific file in remote computer?

Hi,
How can I get information of specific file in remote computer?
I want to get file's status in other computer, this file belongs to shared
directory, I want to get the file size, existanse of the file ...,
When tring to acsess to file or get status it fails, Should I do login to
this computer? if so, how can I do it?

code examples are attached.

Thanks
Yaniv

// example:
if( (_access("\\191.26.58.21\SharedDir\myFile.txt", 0 )) != -1 )
{
printf("file exists");
}
else
{
printf("file not exists");
}

// output:
// file not exists
struct _stat l_StatusBuf;
if(_stat( "\\191.26.58.21\SharedDir\myFile.txt" , &l_StatusBuf ) != -1)
{
printf("got file status");
}
else
{
printf("fail getting file status");
}

// output:
// fail getting file status

Nov 15 '05 #1
1 3635
> How can I get information of specific file in remote computer?
I want to get file's status in other computer, this file belongs to shared
directory, I want to get the file size, existanse of the file ...,


System.IO.FileInfo gives you a lot of this information about the file. Use
UNC (Universal Naming Convetion) for the file name. If you need to specify
credentials to access the remote path, then I sugest you do a "net use ..."
before you run your program.

Hope that helps,
-JG

PS. Here's some sample code:

string fileName = "\\bpdportatil\pub\Bancasol.zip";
FileInfo fi = new FileInfo(fileName);
if (fi.Exists) {
Console.WriteLine("{0} has size: {1}.", fileName, fi.Length);
} else {
Console.WriteLine("{0} does not exist.", fileName);
}
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by DCK | last post: by
1 post views Thread by Bhavya Shah | last post: by
8 posts views Thread by Lam | last post: by
2 posts views Thread by Martin | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.