Results 1 to 6 of 6

Thread: File exists on server

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: File exists on server

    I guess one of the easier things to do is use ifconfig or ipconfig and parse the results.

    The correct way to do this is to use platform specific functions and this will require you to write some code.

    There are only a few things you get for free: the sun going up, death and taxes.
    So don't be lazy and start writing a little bit of code.

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: File exists on server

    To add up to what was posted You could either use QProcess with ping and check result or simply:
    Qt Code:
    1. void MainWindow::someFunction(){
    2. QTcpSocket *sock = new QTcpSocket( this );
    3. connect( sock, SIGNAL(hostFound()), this, SLOT( checkFile() ) );
    4. sock->connectToHost( "192.168.0.2", 421 );
    5.  
    6. }
    7.  
    8. void MainWindow::checkFile()
    9. {
    10. qDebug() << "File Exists?:" << QFile::exists( "\\192.168.0.2\foo\bar.txt" );
    11. }
    To copy to clipboard, switch view to plain text mode 

    or beter use SIGNAL( stateChanged(QAbstractSocket::SocketState) )
    Its add a few lines to Your code and is IMHO simple.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  3. The following user says thank you to Talei for this useful post:

    Chops211 (6th August 2011)

  4. #3
    Join Date
    Aug 2011
    Posts
    14
    Thanks
    1

    Default Re: File exists on server

    Thanks everyone. Using ifconfig or ipconfig doesn't really make sense when I could just use sockets but thank you for the idea.

Similar Threads

  1. Replies: 2
    Last Post: 21st February 2011, 14:52
  2. QFtp:upload file to server
    By ensky_cy in forum Qt Programming
    Replies: 6
    Last Post: 14th December 2009, 10:42
  3. Can't create folder if file with same name exists
    By Barry79 in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2009, 16:33
  4. How to download any file through ftp server
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 01:23
  5. Enctrypted file uploads to a server
    By hardgeus in forum Qt Programming
    Replies: 3
    Last Post: 11th December 2006, 23:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.