i am triing to create an application on a mobile device that checks a file on a server;
the file is located in a shared folder.
i would like to check if the modify date of the file is more recent than the file on the device itself.
if more recent the app would need to download the file to the scanner.
I was able to have the application check if the device has an IP and display it
but when ever i try to connect to the file i get an exception.
Can someone help me please?
I have already tried several ways but here is one that i tried recently (just to check if the file is reachable)
**************************************************************
try
{
FileInfo finfo = new FileInfo(@\\servername\sharedfolder\file.DAT);
if (finfo.Exists)
{
this.label1.Text += "\n" + finfo.CreationTime;
}
else
{
this.label1.Text += "\n" +"file does not exist";
}
}
catch (System.Exception exep)
{ this.label1.Text += "\n" + exep.Message; }
**************************************************************

Pramod Kumar NandagiriRank #6,963 · 252 reputationPosted Feb 24, 2012, 5:59 AM EST
using system.IO;
try
{
if (File.Exists(@"servername\sharedfolder\file.DAT"))
{
this.label1.Text += "\n" + finfo.CreationTime;
}
else
{
this.label1.Text += "\n" +"file does not exist";
}
}
catch (System.Exception exep)
{ this.label1.Text += "\n" + exep.Message; }
Steven6 reputationPosted Feb 27, 2012, 11:58 PM EST
these are the different ways i tried to connect to the file , all result as if the file does not exist...
******************************************************************************
try
{
this.label1.Text += "\n" + System.IO.File.GetCreationTime(@"servername\sharedfolder\file.DAT").ToString();
}
catch (System.Exception ex)
{ this.label1.Text += "\n" + ex.Message; }
******************************************************************************
******************************************************************************
try
{
FileInfo finfo = new FileInfo(@"servername\sharedfolder\file.DAT");
if (finfo.Exists)
{
this.label1.Text += "\n" + finfo.CreationTime;
}
else
{
this.label1.Text += "\n" +"file does not exist";
}
}
catch (System.Exception exep)
{ this.label1.Text += "\n" + exep.Message; }
******************************************************************************
******************************************************************************
try
{
System.IO.FileStream FS = new FileStream(@"servername\sharedfolder\file.DAT", FileMode.Open);
StreamReader SR = new StreamReader(FS);
this.label1.Text = SR.ReadLine();
}
catch (System.Exception ef)
{ this.label1.Text = ef.GetType().ToString(); }
******************************************************************************