Thursday, 15 July 2010

regex - program not writing to file but will write to console in c# -


I have a C # program and it will not be written in a file, but the console, write even if file write line the first console I've tried several modifications, as well as run through debug, and it never writes to files or only

  // file read line Inserts a line in the file displayed in the line. System.IO.StreamReader File = New System. IOOStream Reader ("urltest.txt"); String myFileName = String.Format ( "{0} _ {1}", DateTime.Now.ToString ( "yyyymmddhh"), "-urlcheck .log "); While ((line = file.readline ()) = null () = Uriyyyuri = new Uri (line); Using (StreamWriter writer = new StreamWriter (myFileName) tried) {// (myUri) Web request and response has been URL that // just urltest.txt HttpWebRequest reqFP = (HttpWebRequest) read HttpWebRequest.Create file access Made on the basis of HttpWebResponse rspFP = (HttpWebResponse) reqFP.GetResponse (); If (HttpStatusCode.OK == rspFP.StatusCode) {// HTTP = 200 - Internet connection is available, the server online // Write log file URL to writer.WriteLine ( "status ========== = ================================================== ==== ========= "); Author. Rightline ("back position code: OK" + myUri + "This URL is not blocked!"); Console.light line ("back position code: ok" + myUri + "this url is not blocked!"); Var _uri = myUri.ToString (); String _catstr1 = catURL (_uri); // regex to get the last 8-9 of the line and Regex pat = New Regex (@ "& lt; / (. *?) A"); String _catstr = pat.Replace (_catstr1, "\ x20"); // Write the classification of the URL to write and continue to the author. WrightLine ("URL" + _catstr); Console.light line ("url" + _catstr); }}    

Most should be even writes out to a file either Using a block inside or manually fade and closed.

 using  (var author = ...) {// your writing} //   

Note: I am not a big fan of var , but I do not know what you call it Using a square, at least one valid example is code

No comments:

Post a Comment