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

Popular posts from this blog

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -