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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top