473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

unbelievable..?

Hi all,

I recently built a small prototype smart device project with C# under
VS2005 SP1, and was surprised to see that a 'trivial' statement
did not work to be able to verify the existence of a file that I had created

i.e. System.IO.File.Exists(filename)

I verified the existence of the file by getting a command prompt window and
issuing a dir command. i.e. dir c:\train.zip

Can someone please let me know what can be wrong?

Thanks,

Carlos.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlServerCe;

namespace mything

{

public partial class Form1 : Form

{

//private System.Windows.Forms.MainMenu mainMenu1;

string filename = @"C:\train.zip";

public Form1()

{

InitializeComponent();

}

private void DeleteDB()

{

try

{

if (System.IO.File.Exists(filename)) //does not find it %$#@!

{

System.IO.File.Delete(filename);

}

}

catch (Exception ex)

{

;

}

}

private void Form1_Load(object sender, EventArgs e)

{

DeleteDB();

}

}


Feb 2 '07 #1
3 1347
Your program can find the file and not be able to delete it (read-only or
ACLs). The exception handler in your example catch all and don't say
anything...

/LM
"Carlos" <ch******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi all,

I recently built a small prototype smart device project with C# under
VS2005 SP1, and was surprised to see that a 'trivial' statement
did not work to be able to verify the existence of a file that I had
created

i.e. System.IO.File.Exists(filename)

I verified the existence of the file by getting a command prompt window
and
issuing a dir command. i.e. dir c:\train.zip

Can someone please let me know what can be wrong?

Thanks,

Carlos.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlServerCe;

namespace mything

{

public partial class Form1 : Form

{

//private System.Windows.Forms.MainMenu mainMenu1;

string filename = @"C:\train.zip";

public Form1()

{

InitializeComponent();

}

private void DeleteDB()

{

try

{

if (System.IO.File.Exists(filename)) //does not find it %$#@!

{

System.IO.File.Delete(filename);

}

}

catch (Exception ex)

{

;

}

}

private void Form1_Load(object sender, EventArgs e)

{

DeleteDB();

}

}


Feb 3 '07 #2
Where are you trying to run the application? You are stating it's a smart
device project. Are you running it in the emulator? In the device? Directly
under Windows? Please note that files on your disk don't exist for the
emulator, nor for you smart device.

"Carlos" <ch******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi all,

I recently built a small prototype smart device project with C# under
VS2005 SP1, and was surprised to see that a 'trivial' statement
did not work to be able to verify the existence of a file that I had
created

i.e. System.IO.File.Exists(filename)

I verified the existence of the file by getting a command prompt window
and
issuing a dir command. i.e. dir c:\train.zip

Can someone please let me know what can be wrong?

Thanks,

Carlos.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlServerCe;

namespace mything

{

public partial class Form1 : Form

{

//private System.Windows.Forms.MainMenu mainMenu1;

string filename = @"C:\train.zip";

public Form1()

{

InitializeComponent();

}

private void DeleteDB()

{

try

{

if (System.IO.File.Exists(filename)) //does not find it %$#@!

{

System.IO.File.Delete(filename);

}

}

catch (Exception ex)

{

;

}

}

private void Form1_Load(object sender, EventArgs e)

{

DeleteDB();

}

}


Feb 3 '07 #3
Carlos wrote:
Hi all,

I recently built a small prototype smart device project with C# under
VS2005 SP1, and was surprised to see that a 'trivial' statement
did not work to be able to verify the existence of a file that I had
created

i.e. System.IO.File.Exists(filename)

I verified the existence of the file by getting a command prompt window
and issuing a dir command. i.e. dir c:\train.zip

Can someone please let me know what can be wrong?

Thanks,

Carlos.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlServerCe;

namespace mything

{

public partial class Form1 : Form

{

//private System.Windows.Forms.MainMenu mainMenu1;

string filename = @"C:\train.zip";

public Form1()

{

InitializeComponent();

}

private void DeleteDB()

{

try

{

if (System.IO.File.Exists(filename)) //does not find it %$#@!

{

System.IO.File.Delete(filename);

}

}

catch (Exception ex)

{

;

}

}

private void Form1_Load(object sender, EventArgs e)

{

DeleteDB();

}

}
Hi,

You have a blank exception handler. This is bad. Your exception handlers
should have someway of reporting what's going on, when an exception
happens. An exception happens for a reason; it's an "exceptional
circumstance" and if you're program is doing nothing about it, then you may
run into trouble when it comes to debugging.

It may be unrelated, however, is it not working because you are getting an
exception, or is it not working because you never enter the 'if' block?

--
Hope this helps,
Tom Spink

Google first, ask later.
Feb 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: trode | last post by:
It seems that if my WSDL source goes offline SOAPClient() creates un-trappable fatal errors. I don't think this is right. Shouldn't this be, at very least, trappable exceptions? This is the...
0
by: Lynn & Lilibeth | last post by:
ATTENTION; Finding it tough to make money on the Internet? Want to know some well guarded secrets that will essentially make all the difference between not making money and earning a good...
5
by: Old Wolf | last post by:
The following code causes a deallocation of a random amount of bytes, with the Rogue Wave STL supplied with Borland C++ 5.5.1 : #include <vector> int main() { std::vector<char> v, w(1); v =...
6
by: Gert Brinkmann | last post by:
Hello, as I understand the specs http://www.w3.org/TR/CSS21/visuren.html#x19 an absolute positioned block element is positioned relative to its parent element. This is told in the german...
3
by: Amar | last post by:
Hi everyone, I am trying now for 4-5 hours to write a simple code to validate a very simple XML and i still get an error. Here is my Code, and i always get an error at args.Exception ("The...
2
by: George Addison | last post by:
Every now and again, I make a mistake in ASP.Net code causing an absolute catastrophe when it is encountered by a browser. The site stalls, and even the FTP is inaccessible--it freezes my browser...
2
by: Dimitris Pantazopoulos | last post by:
Hello. I am trying to do the simplest of things. These are exactly the steps I follow: 1. create an sqlConnection to an SQL Server database. 2. create a DataSource and produce a DataSet to a...
11
by: Oleg | last post by:
Here's what happening. On 'page1.aspx' I redirect to 'page2.aspx': Response.Redirect("page2.aspx", true); On 'page2.aspx' I'm redirecting to 'page3.aspx': Response.Redirect("page3.aspx", true);...
2
by: 4.spam | last post by:
Hello. v8.2.1 Anybody can try this: ---------- --base table DECLARE GLOBAL TEMPORARY TABLE SESSION.T (I INT) with replace on commit preserve rows; --insert 10 rows into table t INSERT INTO...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.