473,795 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in creating file and writing in the file

60 New Member
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.tx t";

LogFileName = Application.Exe cutablePath + "\\" + LogFileName;

This return path like this

"F:\\Joe Don't Delete\\DotNet_ Samples\\ADM\\A DM\\ADM\\bin\\D ebug\\ADM.EXE\\ ADM_Log.txt"

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

Code:
File.Create(Log FileName);

The error message is shown like this:"Could not find a part of the path 'F:\\Joe Don't Delete\\DotNet_ Samples\\ADM\\A DM\\ADM\\bin\\D ebug\\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(s Message);
sw1.Close();
}


Please help me these all my problems

Thank u
Mar 23 '07 #1
4 2061
kenobewan
4,871 Recognized Expert Specialist
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
joerozario
60 New Member
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
joerozario
60 New Member
yes i have solved my problem

by

// is not a problem

File.Create(fil eName).Close();

so that i colud open file in stream wrighter

thank u
Mar 28 '07 #4
kenobewan
4,871 Recognized Expert Specialist
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
1972
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 not .zip). (I know these code sections use outside variables, but it's probably pretty clear what the outside variables are -- if not, I can clarify.) I read the files in this way: int i = 0; byte bIn = new byte, bData;
6
4759
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 class I define. It works perfectly on an old machine (PII-400) running Python 2.2.1 under RedHat Linux 8.0. When I try to run it under Python for windows ME on a P-4 1.4 GHz, however, it keeps crashing on reading from the shelved file the second...
2
4093
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 -- talks to --> Perl backend Perl backend -- talks to --> Python plugin Python plugin -- talks to --> Python script
2
1352
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 the capabilities of file. All works fine, except for one thing: 'print >> myfile' does not execute Myfile.write(), it executes the file.write(). If I execute myfile.write() explicitly, then Myfile.write() is called as expected.
5
13292
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 = "application/vnd.ms-word" to create the actual document. My problem is that I want to place a picture (which resides on the server) into the word document as well. However all I seem to get is the place for the image but a picture of an "x" meaning that the...
3
3454
by: Gurikar | last post by:
Hello, I have small clafification. #include<fstream> #include<iostream> using namespace std; void main() { ofstream ofs;
4
3919
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. I used VS.NET 2003 to create a C# client that successfully processes SOAP messages to and from the Java service. However, I'm having problems with the C++ client. I created a new solution and a new project with File > New > Visual C++ Projects...
10
4030
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
7
2322
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, the other in which I close the FileStream afterwards, although both return the same error. Here are the two versions of the code and the errors they each return (NOTE: I rebooted immediately before running each of these versions so that I knew they...
6
2347
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 solution. My code can be downloaded from here: http://www.tprimke.net/konto/PyObject-problem.tar.bz2. There are some scripts for GNU/Linux system (bash to be precise). All you need to know is that there are four classes. (Of course, you may...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.