c# - Split a Folder Path and File Name -
this question has answer here:
- getting folder name(s) path 6 answers
i have folder path , file name want split it. 2 paths : f:\autoimport - folder\20141612\inv.trg
, f:\emailimport\rohan@yahoo.com_01-01-2014_05-05-22\inv.trg
.
so want split path , want "rohan" name , "20141612" path. please suggest how can achieve in .net using c# coding.
this name needed used custom name in kofax capture batch name. of batch name is: 45- f:\emailimport\ram@afcl.com_09-01-2014_10-02-30\new text document.trg. don't know 45- came , batch name coming sample script giving kofax.
here output. using string.split()
can achieve :
string filepath1 = @"f:\emailimport\rohan@yahoo.com_01-01-2014_05-05-22\inv.trg"; system.io.fileinfo fif = new system.io.fileinfo(filepath1); string folderdet = fif.directory.name; string[] arr1 = folderdet.split('@'); string myname = arr1[0]; console.writeline(myname); string filepath2 = @" f:\autoimport - folder\20141612\inv.trg"; system.io.fileinfo fileinfo = new system.io.fileinfo(filepath2); string foldername = fileinfo.directory.name; console.writeline(foldername);
check , let me know if have issues.
Comments
Post a Comment