473,396 Members | 1,875 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,396 software developers and data experts.

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.006",FileMode.OpenOrCr eate,FileAccess.Read) ;
stream1.Close();
}
catch
{
Directory.CreateDirectory(@"c:\trial");

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

FileStream stream = new
FileStream(@"c:\trial\trial.006",FileMode.Create,F ileAccess.Write) ;
stream.Close();
}

Nov 15 '05 #1
3 1257
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)paldino=at=exisconsulting<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.006",FileMode.OpenOrCr eate,FileAccess.Read) ;
stream1.Close();
}
catch
{
Directory.CreateDirectory(@"c:\trial");

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

FileStream stream = new
FileStream(@"c:\trial\trial.006",FileMode.Create,F ileAccess.Write) ;
stream.Close();
}

Nov 15 '05 #2
On Tue, 7 Oct 2003 13:43:52 -0400, "Nicholas Paldino [.NET/C# MVP]"
<ni**************@exisconsulting.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**************@exisconsulting.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
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...
1
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...
3
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...
12
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...
0
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...
1
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?...
1
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: ...
17
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: ...
3
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...
23
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.