I'm trying to figure out why when this runs, it runs with no errors but I'm not seeing a txt file outputed to the location I specified. I've replaced some of the filepath with sss for privacy purposes. If the compiler isn't giving any errors, then why isn't it creating the text file? All I see happens is the windows form defined in my code pops up...do I even need that if this is gonna be run as a scheduled task anyway?
What should I look at?
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("\\sss\f$\inetpub\wwwroot\sss\ssis\maintenance\sss\phase2\sss_input\sss_input.txt")
Dim input As String
input = sr.ReadLine()
While Not input Is Nothing
Dim sw As StreamWriter = New StreamWriter("\\sss\f$\inetpub\wwwroot\sss\ssis\maintenance\sss\phase2\sss_output\sss_output_test.txt")
sw.Write(input)
sw.Close()
End While
Catch E As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(E.Message)
End Try
End Sub
End Class
I am not really following the logic there, especially the part where you are saying: "if input is nothing" (if that is the check to see if the file exists, System.IO.File.Exists is a much much better way of checking that)
Outside of that failure to follow your logic, try using a less complicated path to try to write to... for instance, try using "c:\temp", which is local to your application and your app probably has write permissions there... what will this do?
- Well, if your app works, then this tells you that the problem you are hitting is more than likely related to permissions on the other machine
- If your app still doesn't work, something is amiss with your code
0 comments:
Post a Comment