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

  • Thread starter Thread starter Yaniv M
  • Start date Start date
Y

Yaniv M

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
 
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);
}
 
Back
Top