Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

FileSystem.WriteAllText (broken methodl)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jared - 11 Jul 2006 07:30 GMT
Hi - I am trying to dynamically write vbscript file to c drive.  But it will
not execute.  I have notice some crap in windiff which suggest that VB has
unusual way of creating a file. Anyway it doesn't work and I was hoping to
use the script to bypass some chunky .NET schedule task code.

Anyone know about creating VBS file from VB.NET?

'--code below

Dim c As Char = """"c
Dim s As String
   s = "WScript.Echo " + c + "Hello World" + c
   My.Computer.FileSystem.WriteAllText("c:\test.vbs", s, False)
Herfried K. Wagner [MVP] - 11 Jul 2006 10:57 GMT
"Jared" <jared@dfidfoe.com> schrieb:
> Hi - I am trying to dynamically write vbscript file to c drive.  But it
> will not execute.  I have notice some crap in windiff which suggest that
> VB has unusual way of creating a file.

Maybe you are seeing an UTF-8 BOM (Byte Order Mark) at the beginning of the
file.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Herfried K. Wagner [MVP] - 12 Jul 2006 10:33 GMT
Addendum:

> Maybe you are seeing an UTF-8 BOM (Byte Order Mark) at the beginning of
> the file.

The overloaded version of 'WriteAllText' accepts an 'Encoding' object.  Pass
in 'System.Text.Encoding.Default' to use the systems ANSI CP.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>

Jared - 12 Jul 2006 01:04 GMT
WriteAllText is poor method

use StreamWriter ...

Dim writer As IO.StreamWriter = IO.File.CreateText(xPath)

   writer.WriteLine(xText)
   writer.Close()

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.