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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yaniv M

    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\Share dDir\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\myFi le.txt" , &l_StatusBuf ) != -1)
    {
    printf("got file status");
    }
    else
    {
    printf("fail getting file status");
    }

    // output:
    // fail getting file status



  • Juan Gabriel Del Cid

    #2
    Re: How can I get information of specific file in remote computer?

    > How can I get information of specific file in remote computer?[color=blue]
    > 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 ...,[/color]

    System.IO.FileI nfo 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.zi p";
    FileInfo fi = new FileInfo(fileNa me);
    if (fi.Exists) {
    Console.WriteLi ne("{0} has size: {1}.", fileName, fi.Length);
    } else {
    Console.WriteLi ne("{0} does not exist.", fileName);
    }


    Comment

    Working...