473,320 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem in creating file and writing in the file

In .net 2005 I have created Application

I want to create a log file, which maintains all the internal process so at the run time I want to create a file at the source

Code:

Private string LogFileName = "ADM_Log.txt";

LogFileName = Application.ExecutablePath + "\\" + LogFileName;

This return path like this

"F:\\Joe Don't Delete\\DotNet_Samples\\ADM\\ADM\\ADM\\bin\\Debug\ \ADM.EXE\\ADM_Log.txt"

1. Why the path is return with \\?
2. If I use this path in

Code:
File.Create(LogFileName);

The error message is shown like this:"Could not find a part of the path 'F:\\Joe Don't Delete\\DotNet_Samples\\ADM\\ADM\\ADM\\bin\\Debug\ \ADM.EXE\\ADM_Log.txt'."

If i give manually path with single \

It creates the File.

Then

I use this function to write information in the file
At first the file is created in single \ then it goes to this function
At first line of this function it throws message "the file is exclusively opened by another user"


Private void WriteLog(string sMessage)
{

StreamWriter sw1 = File.AppendText(LogFileName);
sMessage = ("::" + sMessage);
sw1.WriteLine(sMessage);
sw1.Close();
}


Please help me these all my problems

Thank u
Mar 23 '07 #1
4 2038
kenobewan
4,871 Expert 4TB
I assume that you are using two \ for paths as a single is a special char in C#. I thought that this was /, but maybe its both.
Mar 26 '07 #2
whern we see the returend path in debuger it is show in \\

thats whe i have concodinated with \\

any problem in my code?
Mar 26 '07 #3
yes i have solved my problem

by

// is not a problem

File.Create(fileName).Close();

so that i colud open file in stream wrighter

thank u
Mar 28 '07 #4
kenobewan
4,871 Expert 4TB
Congratulations! Thanks for sharing the solution.
Mar 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hal Vaughan | last post by:
I am using OpenOffice files in my app. They're stored in .zip format, so the zip format is much more important, in this case, than that they're OOo files (other than that the extension is .sxw and...
6
by: Rami A. Kishek | last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I hope someone here can shed some light. First of all, I have this piece of code which uses shelve to save instances of some...
2
by: marco | last post by:
Hello, I having a problem creating directories with Python 2.3.4 (compiled with gcc 3.2.2, under Linux 2.4.20-31.9). I'm writing a plugin which works in the following way: GUI --...
2
by: Pierre Rouleau | last post by:
Hi all! I'm trying to extend the functionality of the file object by creating a class that derives from file. MyFile class re-implements __init__(), write(), writelines() and close() to augment...
5
by: Joan | last post by:
I am creating a word document from an asp page. I have no problems actaully creating the document and creating some tables that have data in them. I am using Response.ContentType =...
3
by: Gurikar | last post by:
Hello, I have small clafification. #include<fstream> #include<iostream> using namespace std; void main() { ofstream ofs;
4
by: Mike Woinoski | last post by:
(I'm new to VS, so please forgive me if this is a faq.) I'm writing some Java web services and need to test them with C++ clients. I can use either a Windows Form application or an MFC application....
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.