LastIndexOf

G

Guest

I am trying to check LastIndexOf "\" in a File Path, if it not there i want
to append a "\"

for some reason it throws error?

int index = filePath.LastIndexOf("\");

Any suggestions...

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
---------------
 
G

Guest

Howdy,


public static string AppendDirSeparator(string path)
{
if (String.IsNullOrEmpty(path))
return String.Empty;

if (path[path.Length - 1] == System.IO.Path.DirectorySeparatorChar)
return path;
else
return path + System.IO.Path.DirectorySeparatorChar;
}
 

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

Similar Threads

FileStream 2
HashTable 3
MVC comparing url value with item in model 2
js 2
postback 1
LDAP 1
reg 1
Datagrid Paging 1

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top