File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable
File I/O works in debug but not in executable File I/O works in debug but not in executable
File I/O works in debug but not in executable
Go Back  Xtreme Visual Basic Talk > > > File I/O works in debug but not in executable


Reply
 
Thread Tools Display Modes
  #1  
Old 08-16-2013, 12:05 PM
shingabiss shingabiss is offline
Newcomer
 
Join Date: Nov 2003
Posts: 4
Default File I/O works in debug but not in executable


I have code that is able to write to a file in the debug mode but gets a 'permission denied" error when I run the executable. Here's the pertinent code below:

Dim DateOfTest As Date
Dim TesterName As String
Dim SerialNumber As String

TesterName = TextBoxTester.Text
DateOfTest = Now
SerialNumber = TextBoxBoardSN.Text

'File writing for test info
Dim path As String = "C:\" & SerialNumber & ".txt"

If File.Exists(path) Then
File.Delete(path)
End If

' Create the file.
Dim writer As StreamWriter = New StreamWriter(path)

writer.WriteLine("CPX Loopback Test " & vbCrLf)
writer.WriteLine("Serial Number " & vbTab & "Tester Name" & vbTab & "Date")
writer.WriteLine(SerialNumber & vbTab & vbTab & TesterName & vbTab & vbTab & DateOfTest & vbCrLf)
Reply With Quote
  #2  
Old 08-17-2013, 12:48 AM
Flyguy's Avatar
FlyguyFile I/O works in debug but not in executable Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,163
Default

On all versions of Windows after XP you don't have access rights to write to the root of C:\
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable File I/O works in debug but not in executable
File I/O works in debug but not in executable
File I/O works in debug but not in executable
 
File I/O works in debug but not in executable
File I/O works in debug but not in executable
 
-->