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

c++ - Function signature as a function template parameter -

How to call a javascript function after the page loads with a chrome extension? -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -