@ symbol in C#

K

Karsten Schramm

Hi,
What is the point of running this code?

To see, if his path is really existing
It seems pretty established the the OP does not realize that the exception he
is getting has nothing to do with the @ modifier in front of the string
declaration [or as it appears in the debugger].

I'm aware of that I because he does not understand we have to show him.
 
G

Guest

Hello Everyone,

Sorry, I was in a meeting. I thank everyone for posting your comments here
and I just would like you to know I'm still fairly new to C#.

I have tried the System.Diagnostics.Trace.WriteLine(strSourceDirectory);
statement and yes the acutual path is C:\Documents and Settings\loescsc\My
Documents\Excel\Excel\ like all of you have been saying. However, that does
not answer my question because my app is still interpeting the @ sign in the
path. Here is the actual Exception error I am getting when I try to open the
file:

@"'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure that
the path name is spelled correctly and that you are connected to the server
on which the file resides."

I took the entire path with-out the @ sign and pasted in Windows Explorer
and it opened the file just fine.

Thanks,
 
N

Noah Sham

SAL, why don't you use a debugger and step through your code. I think you
will find that the problem is in ProcessFile(). For shits and grins replace
the call to ProcessFile(strFileName) with

ProcessFile(@""'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv""")

What are you doing in ProcessFile?
 
J

Jon Skeet [C# MVP]

SAL said:
Sorry, I was in a meeting. I thank everyone for posting your comments here
and I just would like you to know I'm still fairly new to C#.

I have tried the System.Diagnostics.Trace.WriteLine(strSourceDirectory);
statement and yes the acutual path is C:\Documents and Settings\loescsc\My
Documents\Excel\Excel\ like all of you have been saying. However, that does
not answer my question because my app is still interpeting the @ sign in the
path.

No, it really, really isn't. The @ sign isn't in the path. It's an
artifact of the debugger. That's all.
Here is the actual Exception error I am getting when I try to open the
file:

How are you finding out that error message? Still in the debugger, by
any chance?
@"'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure that
the path name is spelled correctly and that you are connected to the server
on which the file resides."

I took the entire path with-out the @ sign and pasted in Windows Explorer
and it opened the file just fine.

Then something different is wrong. It's got nothing to do with the @.
 
M

mpetrotta

SAL said:
I have tried the System.Diagnostics.Trace.WriteLine(strSourceDirectory);
statement and yes the acutual path is C:\Documents and Settings\loescsc\My
Documents\Excel\Excel\ like all of you have been saying. However, that does
not answer my question because my app is still interpeting the @ sign in the
path. Here is the actual Exception error I am getting when I try to open the
file:

@"'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure that
the path name is spelled correctly and that you are connected to the server
on which the file resides."

I smell the debugger sneaking back in.

Forget the debugger. Really. It lies to you. Tie it up to a tree for
an hour. Take "Start Debugging" out of your menu list for the
afternoon, map "F5" to "Control-F5", and do this:

try
{
openFileWithPath(path);
}
catch (IOException e)
{
Console.WriteLine(e.Message);
}

I guarantee, with everything in my wallet at the moment, that the '@'
is not in your path string. Look at the console output above, and
you'll see.

Michael
 
J

John B

SAL said:
Hello,

I do not have any trouble declaring string values except when it comes to
directory path's. Why does C# implicitly put a @ symbol at the being of a
String value that has been declared like this:

string strSourceDirectory="C:\\Documents and Settings\\admin\\My
Documents\\Excel\\Excel\\";

The value that strSourceDirectory gets assigned is:

@"C:\Documents and Settings\admin\My Documents\Excel\Excel\"

How do I get around this because my program errors out, because the
directory path in strSourceDirectory that I am assigning to a specific
document I want to open does not exist?

Here is the acutal error I get:

@"'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure that
the path name is spelled correctly and that you are connected to the server
on which the file resides."

Thanks,
The space between "My" and "Documents" needs to be escaped.
Wrap the whole string in double quotes and all will be good
"\"C:\\Documents and Settings\\....\""

Any paths with spaces in them need to be quoted. Win Explorer does this
for you.

JB
 
J

Jon Skeet [C# MVP]

John B said:
The space between "My" and "Documents" needs to be escaped.
Wrap the whole string in double quotes and all will be good
"\"C:\\Documents and Settings\\....\""

That's for the sake of command shells - it doesn't apply to the .NET
API as far as I'm aware.
Any paths with spaces in them need to be quoted. Win Explorer does this
for you.

That's certainly not true for Directory.GetFiles, at least in XP. For
instance, this fails:

using System;
using System.IO;

class Test
{
static void Main()
{
foreach (string file in Directory.GetFiles
("\"c:\\my test dir\""))
{
Console.WriteLine (file);
}
}
}

but this succeeds:

using System;
using System.IO;

class Test
{
static void Main()
{
foreach (string file in Directory.GetFiles (@"c:\my test dir"))
{
Console.WriteLine (file);
}
}
}
 
J

John B

Jon said:
That's for the sake of command shells - it doesn't apply to the .NET
API as far as I'm aware.
<...>
Doh!
I stand corrected :)
I'll be in the corner kicking the cat.

:)

JB
 
G

Guest

Hello,

A new day and fresh mind. Yes, your are right I am doing some unnecessary
checks, but I was only doing that to find out what was the problem. It
didn't dawn on me until this morning that the following code:

string strSourceDirectory="C:\\Documents and Settings\\loescsc\\My
Documents\\Excel\\Excel\\";
string [] strarrDirectoryNames= Directory.GetDirectories(strSourceDirectory);

Found the directory path just fine. I tested this by giving
strSourceDirectory a bogus directory and sure enough it failed immediately
just like you said it would. The Exception error it's giving me is
misleading then. Here is the code in my ProcessFile() where I get the
exception error:

try
{

Database db = DatabaseFactory.CreateDatabase("Microsoft.Jet.OLEDB.4.0",
strDBSourceDirectory, DBProviderType.OLEDB);

//string sqlCommand = "Select * From [ExtractData]";
string sqlCommand = "Select * From " + strDBSourceDirectory;

DBCommandWrapper dbCommandWrapper =
db.GetSqlStringCommandWrapper(sqlCommand);

StringBuilder readerData = new StringBuilder();

using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper))
{
DataTable newDataTable = new DataTable();
newDataTable= CreateDataTable("AP");


// Iterate through DataReader
while (dataReader.Read())
{
DataRow row;
row = newDataTable.NewRow();

// Get the value of the 'Name' column in the DataReader
rowcount++;

row["Invoice_No"] = dataReader["Invoice_No"].ToString();
row["Invoice_Date"] = dataReader["Invoice_Date"].ToString();
row["Equipment_ID"] = dataReader["Equipment_ID"].ToString();
row["Invoice_Line_Item_Amount"] =
dataReader["Invoice_Line_Item_Amount"].ToString();
row["Authorization_No"] = dataReader["Authorization_No"].ToString();

newDataTable.Rows.Add(row);

}//End while (dataReader.Read())

if (dataReader != null) dataReader.Close();

}//End using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper))
}//End try
catch (Exception ex)
{
// Print error message
Console.WriteLine("Error: {0}",ex.Message.ToString());

}//End catch

This code worked fine in with .xls files, but it should work with .txt and
..csv files as well. To read .xls files I had this line of code
connectionStringData.Parameters.Add(new ParameterData("Extended Properties",
"'Excel 8.0;HDR=Yes;IMEX=1'"));

And I changed it to this for the .txt and .csv files:
connectionStringData.Parameters.Add(new ParameterData("Extended Properties",
"'text;HDR=Yes;FMT=Delimited(,)'"));

I'm using Microsoft Enterprise Library to do my database connections. I
still don't know why it gives this Exception:

@"'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure that
the path name is spelled correctly and that you are connected to the server
on which the file resides."

I can take C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv and paste it in Windows Explorer, and
it will open up the file just fine.

Willy Denoyette said:
| Here is the code I am using:
|
| string strSourceDirectory="C:\\Documents and Settings\\admin\\My
| Documents\\Excel\\Excel\\";
| string [] strarrDirectoryNames=
Directory.GetDirectories(strSourceDirectory);
| string [] strarrFileNames= Directory.GetFiles(strSourceDirectory);
|
| foreach(string strFileName in strarrFileNames)
| {
| if(Directory.Exists(strSourceDirectory))
| {
| // This path is a directory
| if(File.Exists(strFileName))
| {
| // This path is a file
| ProcessFile(strFileName);
| }
| else
| {
| // No File Found
| }
| }
| else
| {
| // No such directory
| }
|
| }// End foreach(string strFileName in strarrFileNames)
|
| I've tried declare the string both ways, with @ and with out and the value
| is always the same @"C:\Documents and Settings\admin\My
| Documents\Excel\Excel\"
|
| As for the Permissions, I have Admin rights to my box, so I have access to
| this directory. Just for simplicity if I declare string
| strSourceDirectory="C:\\temp\\somedirectory\\";, it still gives me the
value
| @"C:\temp\somedirectory\"
|
|

Forget about the @ and tell us which statement throws an exception and what
exception.
Note that you are doing a lot of superfluous checks in your code, if you
call GetFiles, you will get back a list of files in an array
(strarrFileNames), right? Why do you check for the existing of the directory
and the file, if they didn't exist they wouldn't be in the array. That means
you can trim your foreach and keep only:

foreach(string strFileName in strarrFileNames)
{
// This path is a file
ProcessFile(strFileName);
}


Willy.
 
C

Christof Nordiek

Hi, SAL

which statement actually is throwing the Exception?

It has to be either File.Exists(strFileName)
or ProcessFile(strFileName).
The last is a Method of your class, so it has to be another statement in
there.


SAL said:
Here is the code I am using:

string strSourceDirectory="C:\\Documents and Settings\\admin\\My
Documents\\Excel\\Excel\\";
string [] strarrDirectoryNames=
Directory.GetDirectories(strSourceDirectory);
string [] strarrFileNames= Directory.GetFiles(strSourceDirectory);

foreach(string strFileName in strarrFileNames)
{
if(Directory.Exists(strSourceDirectory))
{
// This path is a directory
if(File.Exists(strFileName))
{
// This path is a file
ProcessFile(strFileName);
}
else
{
// No File Found
}
}
else
{
// No such directory
}

}// End foreach(string strFileName in strarrFileNames)

I've tried declare the string both ways, with @ and with out and the value
is always the same @"C:\Documents and Settings\admin\My
Documents\Excel\Excel\"

As for the Permissions, I have Admin rights to my box, so I have access to
this directory. Just for simplicity if I declare string
strSourceDirectory="C:\\temp\\somedirectory\\";, it still gives me the
value
@"C:\temp\somedirectory\"


Chris Dunaway said:
Notice that the @ symbol is *outside* of the quotation marks and is not
part of the string. In C# the @ symbol means that you don't have to
escape the slashes in a string. For example, the following lines are
equivalent:

string s = "c:\\Program Files\\Blah";

string s = @"c:\Program Files\Blah";

Can you show us the code where you're using the string?
 
G

Guest

Check my post under Willy. That might help you.

Christof Nordiek said:
Hi, SAL

which statement actually is throwing the Exception?

It has to be either File.Exists(strFileName)
or ProcessFile(strFileName).
The last is a Method of your class, so it has to be another statement in
there.


SAL said:
Here is the code I am using:

string strSourceDirectory="C:\\Documents and Settings\\admin\\My
Documents\\Excel\\Excel\\";
string [] strarrDirectoryNames=
Directory.GetDirectories(strSourceDirectory);
string [] strarrFileNames= Directory.GetFiles(strSourceDirectory);

foreach(string strFileName in strarrFileNames)
{
if(Directory.Exists(strSourceDirectory))
{
// This path is a directory
if(File.Exists(strFileName))
{
// This path is a file
ProcessFile(strFileName);
}
else
{
// No File Found
}
}
else
{
// No such directory
}

}// End foreach(string strFileName in strarrFileNames)

I've tried declare the string both ways, with @ and with out and the value
is always the same @"C:\Documents and Settings\admin\My
Documents\Excel\Excel\"

As for the Permissions, I have Admin rights to my box, so I have access to
this directory. Just for simplicity if I declare string
strSourceDirectory="C:\\temp\\somedirectory\\";, it still gives me the
value
@"C:\temp\somedirectory\"


Chris Dunaway said:
SAL wrote:
Hi Jon,

Eventually, the directory path will be read from a database table
instead of
hard-coding in my program, but for now while I'm testing I have it
declared
this way. I did a cut-n-paste from the address line in Windows
Explorer to
make sure I had the path correct, but C# is implicitly putting the @
symbol
in front of the path causing errors.


Notice that the @ symbol is *outside* of the quotation marks and is not
part of the string. In C# the @ symbol means that you don't have to
escape the slashes in a string. For example, the following lines are
equivalent:

string s = "c:\\Program Files\\Blah";

string s = @"c:\Program Files\Blah";

Can you show us the code where you're using the string?




:

SAL wrote:
I do not have any trouble declaring string values except when it
comes to
directory path's. Why does C# implicitly put a @ symbol at the
being of a
String value that has been declared like this:

string strSourceDirectory="C:\\Documents and Settings\\admin\\My
Documents\\Excel\\Excel\\";

The value that strSourceDirectory gets assigned is:

@"C:\Documents and Settings\admin\My Documents\Excel\Excel\"

C# isn't doing that at all. It's just what the debugger is showing
you.
The two strings above are the same.

How do I get around this because my program errors out, because the
directory path in strSourceDirectory that I am assigning to a
specific
document I want to open does not exist?

Then the directory doesn't exist - it's nothing to do with the
backslashes.

Did you *mean* to have Excel in there twice, by the way?

Jon
 
W

Willy Denoyette [MVP]

But what do you pass to your function, how is it declared? you need to pass
a filepath NOT a directory! that is, strDBSourceDirectory must point to a
file.

foreach(string strFileName in strarrFileNames)
{
// This path is a file
ProcessFile(strFileName);
}

PLEASE PLEASE post the whole code, and do yourself and us a fovor, add this
line to the beginning of your ProcessFile() function, like ...

.... ProcessFile(string fileToProcess)
{
Console.WriteLine(fileToProcess);

Willy.


| Hello,
|
| A new day and fresh mind. Yes, your are right I am doing some unnecessary
| checks, but I was only doing that to find out what was the problem. It
| didn't dawn on me until this morning that the following code:
|
| string strSourceDirectory="C:\\Documents and Settings\\loescsc\\My
| Documents\\Excel\\Excel\\";
| string [] strarrDirectoryNames=
Directory.GetDirectories(strSourceDirectory);
|
| Found the directory path just fine. I tested this by giving
| strSourceDirectory a bogus directory and sure enough it failed immediately
| just like you said it would. The Exception error it's giving me is
| misleading then. Here is the code in my ProcessFile() where I get the
| exception error:
|
| try
| {
|
| Database db = DatabaseFactory.CreateDatabase("Microsoft.Jet.OLEDB.4.0",
| strDBSourceDirectory, DBProviderType.OLEDB);
|
| //string sqlCommand = "Select * From [ExtractData]";
| string sqlCommand = "Select * From " + strDBSourceDirectory;
|
| DBCommandWrapper dbCommandWrapper =
| db.GetSqlStringCommandWrapper(sqlCommand);
|
| StringBuilder readerData = new StringBuilder();
|
| using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper))
| {
| DataTable newDataTable = new DataTable();
| newDataTable= CreateDataTable("AP");
|
|
| // Iterate through DataReader
| while (dataReader.Read())
| {
| DataRow row;
| row = newDataTable.NewRow();
|
| // Get the value of the 'Name' column in the DataReader
| rowcount++;
|
| row["Invoice_No"] = dataReader["Invoice_No"].ToString();
| row["Invoice_Date"] = dataReader["Invoice_Date"].ToString();
| row["Equipment_ID"] = dataReader["Equipment_ID"].ToString();
| row["Invoice_Line_Item_Amount"] =
| dataReader["Invoice_Line_Item_Amount"].ToString();
| row["Authorization_No"] = dataReader["Authorization_No"].ToString();
|
| newDataTable.Rows.Add(row);
|
| }//End while (dataReader.Read())
|
| if (dataReader != null) dataReader.Close();
|
| }//End using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper))
| }//End try
| catch (Exception ex)
| {
| // Print error message
| Console.WriteLine("Error: {0}",ex.Message.ToString());
|
| }//End catch
|
| This code worked fine in with .xls files, but it should work with .txt and
| .csv files as well. To read .xls files I had this line of code
| connectionStringData.Parameters.Add(new ParameterData("Extended
Properties",
| "'Excel 8.0;HDR=Yes;IMEX=1'"));
|
| And I changed it to this for the .txt and .csv files:
| connectionStringData.Parameters.Add(new ParameterData("Extended
Properties",
| "'text;HDR=Yes;FMT=Delimited(,)'"));
|
| I'm using Microsoft Enterprise Library to do my database connections. I
| still don't know why it gives this Exception:
|
| @"'C:\Documents and Settings\admin\My
| Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure
that
| the path name is spelled correctly and that you are connected to the
server
| on which the file resides."
|
| I can take C:\Documents and Settings\admin\My
| Documents\Excel\Excel\TEST200609050.csv and paste it in Windows Explorer,
and
| it will open up the file just fine.
|
| "Willy Denoyette [MVP]" wrote:
|
| >
| > | > | Here is the code I am using:
| > |
| > | string strSourceDirectory="C:\\Documents and Settings\\admin\\My
| > | Documents\\Excel\\Excel\\";
| > | string [] strarrDirectoryNames=
| > Directory.GetDirectories(strSourceDirectory);
| > | string [] strarrFileNames= Directory.GetFiles(strSourceDirectory);
| > |
| > | foreach(string strFileName in strarrFileNames)
| > | {
| > | if(Directory.Exists(strSourceDirectory))
| > | {
| > | // This path is a directory
| > | if(File.Exists(strFileName))
| > | {
| > | // This path is a file
| > | ProcessFile(strFileName);
| > | }
| > | else
| > | {
| > | // No File Found
| > | }
| > | }
| > | else
| > | {
| > | // No such directory
| > | }
| > |
| > | }// End foreach(string strFileName in strarrFileNames)
| > |
| > | I've tried declare the string both ways, with @ and with out and the
value
| > | is always the same @"C:\Documents and Settings\admin\My
| > | Documents\Excel\Excel\"
| > |
| > | As for the Permissions, I have Admin rights to my box, so I have
access to
| > | this directory. Just for simplicity if I declare string
| > | strSourceDirectory="C:\\temp\\somedirectory\\";, it still gives me the
| > value
| > | @"C:\temp\somedirectory\"
| > |
| > |
| >
| > Forget about the @ and tell us which statement throws an exception and
what
| > exception.
| > Note that you are doing a lot of superfluous checks in your code, if you
| > call GetFiles, you will get back a list of files in an array
| > (strarrFileNames), right? Why do you check for the existing of the
directory
| > and the file, if they didn't exist they wouldn't be in the array. That
means
| > you can trim your foreach and keep only:
| >
| > foreach(string strFileName in strarrFileNames)
| > {
| > // This path is a file
| > ProcessFile(strFileName);
| > }
| >
| >
| > Willy.
| >
| >
| >
 
C

Christof Nordiek

i suppose it's the db.ExecuteReader(dbCommandWraper) that throws the
exception.
And the strDBSourceDirectory contains the path the exception is complaining
about, right?

I'd guess the Statement hasn't the right syntax. Mavbe there should be some
delemiters because of
the spaces in the path or something like that

hth

SAL said:
Hello,

A new day and fresh mind. Yes, your are right I am doing some unnecessary
checks, but I was only doing that to find out what was the problem. It
didn't dawn on me until this morning that the following code:

string strSourceDirectory="C:\\Documents and Settings\\loescsc\\My
Documents\\Excel\\Excel\\";
string [] strarrDirectoryNames=
Directory.GetDirectories(strSourceDirectory);

Found the directory path just fine. I tested this by giving
strSourceDirectory a bogus directory and sure enough it failed immediately
just like you said it would. The Exception error it's giving me is
misleading then. Here is the code in my ProcessFile() where I get the
exception error:

try
{

Database db = DatabaseFactory.CreateDatabase("Microsoft.Jet.OLEDB.4.0",
strDBSourceDirectory, DBProviderType.OLEDB);

//string sqlCommand = "Select * From [ExtractData]";
string sqlCommand = "Select * From " + strDBSourceDirectory;

DBCommandWrapper dbCommandWrapper =
db.GetSqlStringCommandWrapper(sqlCommand);

StringBuilder readerData = new StringBuilder();

using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper))
{
DataTable newDataTable = new DataTable();
newDataTable= CreateDataTable("AP");


// Iterate through DataReader
while (dataReader.Read())
{
DataRow row;
row = newDataTable.NewRow();

// Get the value of the 'Name' column in the DataReader
rowcount++;

row["Invoice_No"] = dataReader["Invoice_No"].ToString();
row["Invoice_Date"] = dataReader["Invoice_Date"].ToString();
row["Equipment_ID"] = dataReader["Equipment_ID"].ToString();
row["Invoice_Line_Item_Amount"] =
dataReader["Invoice_Line_Item_Amount"].ToString();
row["Authorization_No"] = dataReader["Authorization_No"].ToString();

newDataTable.Rows.Add(row);

}//End while (dataReader.Read())

if (dataReader != null) dataReader.Close();

}//End using (IDataReader dataReader = db.ExecuteReader(dbCommandWrapper))
}//End try
catch (Exception ex)
{
// Print error message
Console.WriteLine("Error: {0}",ex.Message.ToString());

}//End catch

This code worked fine in with .xls files, but it should work with .txt and
.csv files as well. To read .xls files I had this line of code
connectionStringData.Parameters.Add(new ParameterData("Extended
Properties",
"'Excel 8.0;HDR=Yes;IMEX=1'"));

And I changed it to this for the .txt and .csv files:
connectionStringData.Parameters.Add(new ParameterData("Extended
Properties",
"'text;HDR=Yes;FMT=Delimited(,)'"));

I'm using Microsoft Enterprise Library to do my database connections. I
still don't know why it gives this Exception:

@"'C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv' is not a valid path. Make sure
that
the path name is spelled correctly and that you are connected to the
server
on which the file resides."

I can take C:\Documents and Settings\admin\My
Documents\Excel\Excel\TEST200609050.csv and paste it in Windows Explorer,
and
it will open up the file just fine.

Willy Denoyette said:
| Here is the code I am using:
|
| string strSourceDirectory="C:\\Documents and Settings\\admin\\My
| Documents\\Excel\\Excel\\";
| string [] strarrDirectoryNames=
Directory.GetDirectories(strSourceDirectory);
| string [] strarrFileNames= Directory.GetFiles(strSourceDirectory);
|
| foreach(string strFileName in strarrFileNames)
| {
| if(Directory.Exists(strSourceDirectory))
| {
| // This path is a directory
| if(File.Exists(strFileName))
| {
| // This path is a file
| ProcessFile(strFileName);
| }
| else
| {
| // No File Found
| }
| }
| else
| {
| // No such directory
| }
|
| }// End foreach(string strFileName in strarrFileNames)
|
| I've tried declare the string both ways, with @ and with out and the
value
| is always the same @"C:\Documents and Settings\admin\My
| Documents\Excel\Excel\"
|
| As for the Permissions, I have Admin rights to my box, so I have access
to
| this directory. Just for simplicity if I declare string
| strSourceDirectory="C:\\temp\\somedirectory\\";, it still gives me the
value
| @"C:\temp\somedirectory\"
|
|

Forget about the @ and tell us which statement throws an exception and
what
exception.
Note that you are doing a lot of superfluous checks in your code, if you
call GetFiles, you will get back a list of files in an array
(strarrFileNames), right? Why do you check for the existing of the
directory
and the file, if they didn't exist they wouldn't be in the array. That
means
you can trim your foreach and keep only:

foreach(string strFileName in strarrFileNames)
{
// This path is a file
ProcessFile(strFileName);
}


Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top