473,770 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File creation problem

I have a coding problem, modelled by the trial code below
I don't understand the error, however elementary this is.
Pleases assist,
Patrick.

try
{
FileStream stream1 = new
FileStream(@"c: \trial\trial.00 6",FileMode.Ope nOrCreate,FileA ccess.Read) ;
stream1.Close() ;
}
catch
{
Directory.Creat eDirectory(@"c: \trial");

/////////////////////// I get an error in the next
line//////////////////////////

FileStream stream = new
FileStream(@"c: \trial\trial.00 6",FileMode.Cre ate,FileAccess. Write) ;
stream.Close();
}

Nov 15 '05 #1
3 1271
Patrick,

What is the problem you are coming across? Is an exception thrown? If
so, what is the exception? Also, in your code, you should be catching a
specific exception, not just all exceptions. The exception thrown might be
one that indicates that something other than the directory existing is the
problem.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldin o=at=exisconsul ting<dot>com

"Patrick De Ridder" <00*@000.00> wrote in message
news:10******** *******@evisp-news-01.ops.asmr-01.energis-idc.net...
I have a coding problem, modelled by the trial code below
I don't understand the error, however elementary this is.
Pleases assist,
Patrick.

try
{
FileStream stream1 = new
FileStream(@"c: \trial\trial.00 6",FileMode.Ope nOrCreate,FileA ccess.Read) ;
stream1.Close() ;
}
catch
{
Directory.Creat eDirectory(@"c: \trial");

/////////////////////// I get an error in the next
line//////////////////////////

FileStream stream = new
FileStream(@"c: \trial\trial.00 6",FileMode.Cre ate,FileAccess. Write) ;
stream.Close();
}

Nov 15 '05 #2
On Tue, 7 Oct 2003 13:43:52 -0400, "Nicholas Paldino [.NET/C# MVP]"
<ni************ **@exisconsulti ng.com> wrote:
Patrick,

What is the problem you are coming across?


Components of the path cannot be found. That is ther error being
indicated by the debug option.

Which I don't understand because the first part has been created by
the line above and the second part is being created by the line
proper. So I am totally at a loss here.
--
Regards,
Patrick.
Nov 15 '05 #3
On Tue, 07 Oct 2003 21:04:01 +0200, Patrick De Ridder <00*@000.00>
wrote:
On Tue, 7 Oct 2003 13:43:52 -0400, "Nicholas Paldino [.NET/C# MVP]"
<ni*********** ***@exisconsult ing.com> wrote:
Patrick,

What is the problem you are coming across?

The problem has been solved. Many thanks. The learning experience was
to check the availability of the directories at the highest level in
the system structure, which in my case is the main form that calls
child forms as required.

--
Regards,
Patrick.
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3660
by: pdav | last post by:
Hi! Is there any solution to create a directory with one script with mkdir(), and then write a file (or move an uploaded file) in this directory with another script? The problem is, that the directory belongs to the PHP-interpreter (UID 33 in my case) and the script doing the file creation and the one creating the directory belong to the FTP-user (UID 754 in my case).
1
3390
by: fowlertrainer | last post by:
Hi ! 1. Thanx for your answer in the theme of Unicode, and other things. 2. The problem: I need to create an application that not need Python libs to install. Py2Exe is good for that, but I need to copy the "dist" to the network drive what mapped readonly. This is a protection. So: in this time I have been use same applications, but they are created
3
6266
by: zfeld | last post by:
My app is creating a word document which my app calls saveas() and saves it to a given directory that is being watched by a fileSystemWatcher. The problem is that the fileSystemEventHandler for creation is only called for the temporary filed created by word which shows up as ~$documentName.doc the real file named MyDocument.doc will never invoke the fileSystemEventHandler for creation. Now when the user closes Word the temporary file is...
12
2299
by: Riley DeWiley | last post by:
I have a project that is using a Jet backend and having trouble with Jet's tendency to bloat it's MDB file. I can compact it but it is a hassle. I am considering switching to a Fox backend but have not used one. I want to know: 1) Does the Foxpro backend also bloat like this? 2) Is it hard to distribute fox binaries if all you want is bare bones DBMS stuff (I handle all the UI)? RDeW
0
1699
by: Will Arrowsmith | last post by:
Hi All, I am aiming to create a multiframe Tiff file that I can fax using the windows fax service FAXCOMLib. I have created an array of Bitmaps (pages I want in my fax doc) and succesfully converted them all to be 1bppIndexed. I then combine all bitmaps into a single multiframed Tiff file (with CCITT3 compression) before attempting to fax the file. When I call the send method of the fax routine I get the error:
1
2592
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time? My code is creating a file correctly, but the CreationTime is (sometimes) set to the CreationTime of an old file that has previously been removed. The line of code creating the file is _LogFileWriter = newFile.CreateText()
1
2158
by: hagaihe | last post by:
Hello, My application is writing relevent events to log file on local machine. Due to amount of transactions i need to open new log everyday and to save the last one according to the next flow: If the log file exists , check what is the log file creation date , compare it to the running logical day and if they are not the same open new log file and add to the log file name the creation date and copy all the data from current existing...
17
8029
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: I am trying to use the SaveFileDialog class to get a filename, which is subsequently opened for writing (write access, read sharing, but using read/write sharing doesn't make the problem go away anyway). Sometimes, on the statement where I...
3
4500
by: Sean C. | last post by:
Hey All, I'm having a little problem here. I have a project that I'm working on that involves a MySQL server database backend. I'm having no problem creating the database on the fly if it doesn't already exist and using it once it's created. My problem comes into play when I run the program for the first time. I'm wanting to have some kind of flag that lets me know that the database has not yet been created, so that I can call my...
23
1679
by: bc90021 | last post by:
Hi All, Thanks in advance for any and all help! I have this code: g = open(fileName, 'a') where fileName is defined before the line it's used in. It works fine when I use it outside a thread class.
0
10260
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
10038
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
8933
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...
0
6712
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.