Showing posts with label specified. Show all posts
Showing posts with label specified. Show all posts

Monday, March 26, 2012

Text file not being written using System.IO

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

Saturday, March 24, 2012

Text to System.Web.UI.Control

Hi NG!

Is there a function in the .net FX that returns a
System.Web.UI.Control's inherited class for a specified text?
Means, if you specify

<a href="http://links.10026.com/?link=http://www.microsoft.com/" title="Microsoft">Microsoft
Corporation</a
it should return an instance of System.Web.UI.HtmlAnchor or
System.Web.UI.WebControls.LinkButton, where Href, Title, and InnerText
are set appropriately.

Thanks for any hint!

Best regards,

MichaelThere's nothing in .Net to do this...there might be third party tools
though...couldn't quickly find anything..

Karl

"Michael Kremser" <mkspamx-usenet@.yahoo.de> wrote in message
news:%23Q2L26rkEHA.3432@.TK2MSFTNGP14.phx.gbl...
> Hi NG!
> Is there a function in the .net FX that returns a
> System.Web.UI.Control's inherited class for a specified text?
> Means, if you specify
> <a href="http://links.10026.com/?link=http://www.microsoft.com/" title="Microsoft">Microsoft
> Corporation</a>
> it should return an instance of System.Web.UI.HtmlAnchor or
> System.Web.UI.WebControls.LinkButton, where Href, Title, and InnerText
> are set appropriately.
> Thanks for any hint!
> Best regards,
> Michael
Note, that in you example you don't have a server-side control in the first
place since there is no runat=server attribute.

Eliyahu

"Michael Kremser" <mkspamx-usenet@.yahoo.de> wrote in message
news:%23Q2L26rkEHA.3432@.TK2MSFTNGP14.phx.gbl...
> Hi NG!
> Is there a function in the .net FX that returns a
> System.Web.UI.Control's inherited class for a specified text?
> Means, if you specify
> <a href="http://links.10026.com/?link=http://www.microsoft.com/" title="Microsoft">Microsoft
> Corporation</a>
> it should return an instance of System.Web.UI.HtmlAnchor or
> System.Web.UI.WebControls.LinkButton, where Href, Title, and InnerText
> are set appropriately.
> Thanks for any hint!
> Best regards,
> Michael

Text to System.Web.UI.Control

Hi NG!
Is there a function in the .net FX that returns a
System.Web.UI.Control's inherited class for a specified text?
Means, if you specify
<a href="http://links.10026.com/?link=http://www.microsoft.com/" title="Microsoft">Microsoft
Corporation</a>
it should return an instance of System.Web.UI.HtmlAnchor or
System.Web.UI.WebControls.LinkButton, where Href, Title, and InnerText
are set appropriately.
Thanks for any hint!
Best regards,
MichaelThere's nothing in .Net to do this...there might be third party tools
though...couldn't quickly find anything..
Karl
"Michael Kremser" <mkspamx-usenet@.yahoo.de> wrote in message
news:%23Q2L26rkEHA.3432@.TK2MSFTNGP14.phx.gbl...
> Hi NG!
> Is there a function in the .net FX that returns a
> System.Web.UI.Control's inherited class for a specified text?
> Means, if you specify
> <a href="http://links.10026.com/?link=http://www.microsoft.com/" title="Microsoft">Microsoft
> Corporation</a>
> it should return an instance of System.Web.UI.HtmlAnchor or
> System.Web.UI.WebControls.LinkButton, where Href, Title, and InnerText
> are set appropriately.
> Thanks for any hint!
> Best regards,
> Michael
Note, that in you example you don't have a server-side control in the first
place since there is no runat=server attribute.
Eliyahu
"Michael Kremser" <mkspamx-usenet@.yahoo.de> wrote in message
news:%23Q2L26rkEHA.3432@.TK2MSFTNGP14.phx.gbl...
> Hi NG!
> Is there a function in the .net FX that returns a
> System.Web.UI.Control's inherited class for a specified text?
> Means, if you specify
> <a href="http://links.10026.com/?link=http://www.microsoft.com/" title="Microsoft">Microsoft
> Corporation</a>
> it should return an instance of System.Web.UI.HtmlAnchor or
> System.Web.UI.WebControls.LinkButton, where Href, Title, and InnerText
> are set appropriately.
> Thanks for any hint!
> Best regards,
> Michael