c# - Check whether a link to a file is a txt -
i have varaible urllist holds directory of supposed entered in text box, want though, check whether given directory file text file or not, user gets prompted either cancel actions or give in correct file.
code snippet:
public static string urllist = @"c:\users\gbbb\desktop\url.txt"; private string[] _urlrows;
and method sorta started, , realised need for
private void loadurls() { if (urllist == system.text-file) _urlrows = system.io.file.readalllines(@urllist); }
if understand clearly, need use path.getextension
method.
returns extension of specified path string.
string ext = path.getextension(@"c:\users\gbbb\desktop\url.txt"); if(ext == ".txt") { string[] readtext = file.readalllines(@"c:\users\gbbb\desktop\url.txt"); }
Comments
Post a Comment