|
Hi,
Windows does not create the directory if it does not already exist.
Windows Explorer will create directories for you, the programming interfaces don't.
So you have to take care of that yourself using Directory.CreateDirectory.
BTW: there is no need to test, creating a directory that already exists is harmless.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Thanks for your reply.
The directory exists, but the file doesn't. Do I need to create the file? The examples in msdn didn't indicate I need to create the file. Plus, how would I create an empty jpg file?
Thanks again.
Blitz
|
|
|
|
|
You'd better make sure the destination directory exist while coping file.Hope such code can help:
string strPath = AppDomain.CurrentDomain.BaseDirectory + @"UserImages\";
if(!Directory.Exists(strPath))
Directory.CreateDirectory(strPath);
Regards,
Dealon
Impossible is nothing!
|
|
|
|
|
Instead of concatenating the path variable together, use System.IO.Path.Combine. That will automatically handle the backslashes. For your problem: as the other replies have stated, the path to the destination folder doesn't exist. You need to create it
|
|
|
|
|
Thank you for all of your replies.
What I don't understand, however, is that the folder does exist. In fact, the path it shows as not being able to find is, in fact, the correct path to the folder. I need it to place the new file in the folder - which already exists. So the directory already exists.
I apologize for my confusion, but what am I missing?
Thanks,
Blitz
|
|
|
|
|
OMG!!! You all are so right! Thanks. Indeed, it did not exist. See, my error was that I added the "UserImages" folder to my project. However, it was not in my output directory. I failed to realize the difference. Now I know, and knowing is half the battle
Thanks so much for your help.
|
|
|
|
|
Hi
I have added 10 items to ListView control.When i click on the items of listview control it should be added to the column of the TableLayoutPanel.How can i do this?
|
|
|
|
|
I think you'd better create a control(label, textbox,etc..)first associated with that item you clicked, then add to it to your TableLayoutPanel's controls.
Hope can help you.
Regards,
Dealon
Impossible is nothing!
|
|
|
|
|
Hi,
I have two date time picker i want to do as when i increase only the year in the DateTimeOicker 1 Then year of the DateTimeOicker 2 automatically increase for doing this what should i do,
Thanks
Sajjad Ali
|
|
|
|
|
Create an event for the change in DateTimePicker 1. In that event, increment DateTimePicker 2.
|
|
|
|
|
For exemple, i have a string = "%alan#23%12:34:50#ab %regular#]r";
Extract string which enclosed by '%' and '#'
The substring result should be
substr[0] = "alan";<br />
substr[1] = "12:34:50";<br />
substr[2] = "regular";
How to do it in Regex?
8.Kelvin()
{
while (!(the machine can program itself))
Wont_stop_coding = true;
}
|
|
|
|
|
Read up on grouping in regex. You can do exactly this by specifying which parts of your match to return.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
i tried this code..
string str = "%alan#23%12:34:50#ab %regular#]r";
Regex RE = new Regex(@"(\%+)\#");
MatchCollection MC = RE.Matches(str);
if (MC.Count == 0) MessageBox.Show("No match");
foreach (Match M in MC)
{
MessageBox.Show(M.ToString());
}
But when execute it, i only got "No match" message box.
Christian Graus wrote: grouping in regex
I'm not good in grouping regex, pls advise..
8.Kelvin()
{
while (!(the machine can program itself))
Wont_stop_coding = true;
}
|
|
|
|
|
I think i got it..
the regex should be:
Regex RE = new Regex(@"(\%(\w|\: )+)\#");<br />
8.Kelvin()
{
while (!(the machine can program itself))
Wont_stop_coding = true;
}
|
|
|
|
|
Why Not.....
I solved it as i add COM reference Microsoft word 12.0 Object Library.
Then i code this..
try
{
string Msfilename = System.Windows.Forms.Application.StartupPath;
Msfilename = Msfilename + "\\File\\Test.doc";
System.Diagnostics.Process.Start(Msfilename);
}
catch (Win32Exception ex)
{
MessageBox.Show(ex.Message);
}
I got the solution.
|
|
|
|
|
I have a file that I want to read, it's an RTF. I do this:
System.IO.FileStream fStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
( I need a stream to pass to the WPF Rich Text control ). This fails with a permissions error, no matter where in the file system the file is. Any suggestions on how to make Vista work ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
This is real pain. Is it possible to put the file under users folder (users\user name\application data )? I am able to reproduce your issue on my Vista Business and it got solved when I moved the file to the above said directory. Environment.GetFolderPath can be used to get the path.
I have heard about creating manifest files. I haven't tried it yet. Here[^] is the MSDN article for that.
|
|
|
|
|
We have 750 MB of data, I don't want that to be stored per user.
What I found was that File.ReadAllBytes works fine for the same files, and then I can put the bytes into a memory stream. Which, I'm sure you'll agree, is not buggy at all.....
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: What I found was that File.ReadAllBytes works fine for the same files
I was not aware. Glad to hear problem is sorted.
|
|
|
|
|
Christian Graus wrote: I found was that File.ReadAllBytes works fine
Interesting - bookmarked!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
DaveyM69 wrote: Interesting - bookmarked!
damn...I never noticed that message can be bookmarked...thanks man
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi Christian,
from the statement System.IO.FileStream fStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open); Windows does not know whether you will want to read and/or write, hence you may get a File Access Denied situation depending on exact file location.
Try adding System.IO.FileAccess.Read as an extra parameter.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I want to modify windows media player SDK using c# code please anybody can help me in this regard.
|
|
|
|
|
Perhaps you need to reword your question so that it might perhaps indicate something that is physically possible. What do you want to achieve ?
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Hello every one!
I need help with showing dynamic images in my ListView. My ListView has two colums, ImageColum and TittleColum.
I want to display only images dynamic on ImageColum as item without any textstring. TittleColum I want to diplay tittle from my custom objects as subitem.
Could any of you please give me some advices or know where I can get some code eksample in C#?? Many thanks in advance!!
regards
|
|
|
|