I'm using the following code to write some text to a file:
objWriter = New StreamWriter(FullPath, True, System.Text.Encoding.ASCII)
For nRow = 1 To sData.Length - 1
objWriter.WriteLine(sData(nRow))
Next nRow
objWriter.Flush()
objWriter.Close()
When I run this in the IDE, it works. When I compile it and run the EXE, it
doesn't give any errors, but it doesn't create the file either. I've tried
putting a message box in the loop, and the data is acutally there. I've put
this in a try/catch block, but it doesn't catch any error.
I've tried creating a setup package, building it, then running the setup.
Same behavior.
I've also tried just objWriter = New StreamWriter(FullPath), same behavior.
What am I doing wrong? Any ideas or suggestions at all would be
appreciated!
Thanks,
---Selden McCabe 7 3884
Here's some additional information:
The code with the streamwriter was in a separate Class project which was
added to my solution. So this code was running in a DLL separate from the
main executable.
When I copied the code from this class into the form's button_click event,
it worked.
So, for some reason, having the code in a separate DLL causes the problem.
Any ideas why?
Thanks again,
---Selden
Here's some additional information:
The code with the streamwriter was in a separate Class project which was
added to my solution. So this code was running in a DLL separate from the
main executable.
When I copied the code from this class into the form's button_click event,
it worked.
So, for some reason, having the code in a separate DLL causes the problem.
Any ideas why?
Thanks again,
---Selden
I'd say double check the value of the FullPath variable and make sure
the file is being written where you think it is.
How is the FullPath variable being constructed?
I'd say double check the value of the FullPath variable and make sure
the file is being written where you think it is.
How is the FullPath variable being constructed?
Are you referencing the DLL correctly?
Is it necessary to have a streamwriter in a seperate DLL?
Hi Selden,
Have you tried Chris's suggestion?
I agree with Chris's suggestion that the FullPath is not the destination
dir you means.
To verify it, you may try to use a Console.WriteLine(FullPath) to write the
string out to confirm it.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
It's not creating file because of your second parameter. That parameter you have set to true, which is "Append" to existing file.
If the file doesn't exist, it's not going to create it. You need to first check to see if it exist. If it exists, then the second parameter needs to be TRUE otherwise set it for FALSE!
From http://www.developmentnow.com/g/38_2...-sometimes.htm
Posted via DevelopmentNow.com Groups http://www.developmentnow.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Majed |
last post by:
Hi , all
I'm trying to write unicode to a file for another app (not developed with
vs2003) to read it. I used StreamWriter with unicode encoding.but I was
surprised that the streamwriter adds FFFE...
|
by: notalent |
last post by:
I'm having a problem with a very basic program. I'm creating a app in
Visual Studio (2003) C# to zip up a collection of specified files &
directories and save them to a certain location.
I have...
|
by: Lars Hansen |
last post by:
Hi
This is probably pretty basic, but I have a problem with the access-level
(local variable), when creating a new StreamWriter. I am trying to write
some price information to a textfile - which...
|
by: Brendan Miller |
last post by:
Hi,
I have been having a problem writing the contents of a dataset to a .csv
file. When I write to a .csv file and open it with either Excel or Wordpad
the "french" characters are wrong. When I...
|
by: piotrek |
last post by:
Hi.
I would like to ask if there is a method to force streamwriter.writeline()
to write line at the end of existing file, or should i have write the method
for my own.
PK
|
by: Selden McCabe |
last post by:
I'm using the following code to write some text to a file:
objWriter = New StreamWriter(FullPath, True, System.Text.Encoding.ASCII)
For nRow = 1 To sData.Length - 1...
|
by: Don |
last post by:
I'm having problems working with a streamwriter object. After closing the
streamwriter and setting it to Nothing, I try to delete the file it was
writing to, but I always get the following error...
|
by: sameer |
last post by:
Hi,
My very simple application VB.NET Visual Studio 2003 console application
uses a log file to write some text to it. I am using StreamWriter object to
create and open and then append text to...
|
by: Mads Westen |
last post by:
Hi,
I'm parsing some XML files, and converting them to CSV.
I got x number of XML files in a directory, these files do I need to be
converted and written to the same CSV file.
My problem is...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |