i have a code that try to get the file name from the path the file is the code is below
a = @"C:\Documents and Settings\awaduge\Desktop\Purchase Order\Purchase Order Excel\20100427 REQ (ASG NI Framegrabber for ARL Camera).xls"; MessageBox.Show(a.ToString()); int Findex = a.LastIndexOf('\\'); MessageBox.Show("index of a " + Findex.ToString()); int Lindex = a.IndexOf("."); MessageBox.Show("index of s " + Lindex.ToString()); MessageBox.Show("length " + a.Length.ToString()); FileName = a.Substring(Findex,Lindex); MessageBox.Show(FileName);
i want to get the substring "20100427 REQ (ASG NI Framegrabber for ARL Camera)" from the string a defined in the code,
Findex is 77 and Lindex is 127,but actually the index of the last \ is 77. and also when i try to get the file name it gives an exception saying argument out of range exception. but it is not out of range i i complied the code line by line,
why is this coming,
how can i get the file name from the string a ???
Edited 6 Years Ago by judithSampathwa: n/a