|
You can use the function
System.IO.Directory.Exists(myFolderPath) for the same
|
|
|
|
|
Try:
if (filesaveLocation.Contains(@"\CUST\"))
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Thank you for your replies.
I also have to test to see if the directory file path does not = 'CUST', in the directory path called ""C:\RData\CUST\Omaha\book.xlsx". How would you code that change?
|
|
|
|
|
Uhhhh, you're question isn't really clear, but wouldn't the same test work with just the smallest change??
if (filesaveLocation.Contains(@"\CUST\") == false)
|
|
|
|
|
Morning Dave!
Do you need more coffee?
if (!filesaveLocation.Contains(@"\CUST\"))
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
It was WAY past my bedtime.
|
|
|
|
|
|
You're welcome!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
Note that what you are doing here (and what the replies show you how to do) is checking for the presence of a string within another string.
Checking for the "validity" of a Directory, its actual existence, when your program is running, before you take some action, like writing a file to that Directory, is another thing. .NET hands you some excellent tools for checking whether Directories, or Files, actually exist.
The System.IO library offers a host of static methods such as File.Exists("file path"), Directory.Exists("directory file path") to check run-time existence. And, for more complex purposes, you can create an instance of a DirectoryInfo object, which has Properties like .Exists.
There are several reasons that these functions could return 'false: some are obvious, like the fact that the Directory/File doesn't exist any more; others more subtle, like you have some invalid character in the path name.
Based on your questions, I suggest you get a good basic book on C# programming, and study the different operators you can use with a 'string object.
And then, think about what you are going to do if the string you have in your Application Settings is incorrect: that will take you into studying the tools offered by the System.IO library.
Study, experiment, practice, analyze your errors: learn
yours, Bill
“Humans are amphibians: half spirit, half animal; as spirits they belong to the eternal world; as animals they inhabit time. While their spirit can be directed to an eternal object, their bodies, passions, and imagination are in continual change, for to be in time, means to change. Their nearest approach to constancy is undulation: repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
|
|
|
|
|
Hi
I have a to make space invaders for school.
I can move the defender with the mouse and he also shoots with a mouse click but I also want to use the keyboard keys left, right and spacebar.
I don't know how to start for this, please help!
Thank you!
|
|
|
|
|
|
You don't have to do my homework :s I just can't find how to use keyboard keys instead of a mouse control...
This is my project http://pastebin.com/DVewwGmz[^]
|
|
|
|
|
Well, then, it looks like you haven't looked through the list of events for the Form class. I wonder what the KeyDown and KeyUp events are for...
|
|
|
|
|
|
Thank you Collin Jasnoch I will try that!
|
|
|
|
|
Hi All,
The Pen and the Brush objects' Color property needs to be set when they are created. The problem is the color values one can use is very limited. Is there a way to send the color code to the Pen or the Brush object dynamically after choosing a color from a palette? Thanks in advance for your reply.
modified 23-May-13 7:03am.
|
|
|
|
|
You do that by creating a new Pen/Brush with that selected color (do not forget to Dispose() of the old Pen/Brush objects for freeing the resources).
|
|
|
|
|
Hi, thanks for responding. I was already aware of setting the color of the pen or the brush object using the Color.color name method. What I would like to do instead of using color names such as blue, green, red, etc. is pass in the RGB code to the property like the following
Pen myPen = new Pen;
myPen = System.Drawing.Color.F08080;
modified 23-May-13 7:04am.
|
|
|
|
|
Have a look at the FromArgb[^] method of the Color struct, you can set it to anywhere in the 32bit ARGB range. So, you set the Color and pass that to the Pen...
Edit:
using(Pen pen = new Pen(Color.FromArgb(0)))
{
}
replacing the zero with the value you want
|
|
|
|
|
Hi, thanks for your reply. The example in the MSDN below suggests that I must manually set the value of
FromArgb():
public void FromArgb4(PaintEventArgs e)
{
Graphics g = e.Graphics;
// Transparent red, green, and blue brushes.
SolidBrush trnsRedBrush = new SolidBrush(Color.FromArgb(0x78FF0000));
SolidBrush trnsGreenBrush = new SolidBrush(Color.FromArgb(0x7800FF00));
SolidBrush trnsBlueBrush = new SolidBrush(Color.FromArgb(0x780000FF));
}
You've just given me an idea; I'm going to allow users to set the color of the brush or pen object by clicking on the color palette object. This will grab the color code then pass it as a parameter to the FromArgb4() method.
modified 23-May-13 7:03am.
|
|
|
|
|
That's the correct way to do it.
Make sure you put all those brushes in using block(s) or explicitly call Dispose() on each one before you exit your method - unless you are caching them in private fields, in which case you need to make your class IDisposable and implement the Dispose pattern.
|
|
|
|
|
Hi,
I need an additional button including a handler in a System.Windows.Forms.SaveFileDialog() to do customized processing instead of a "Save" as implemented by default. To complicate matters, this dialog is opened from within WPF since WPF itself lacks such dialog.
What are the pieces needed to implement such custom SaveFileDialog(), please?
Thank you!!
|
|
|
|
|
You will need to build your own dialog, just like any other dialog you would build. So you will need to identify the controls you see in the system dialog and reproduce that yourself.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You cannot do much with the existing control.
|
|
|
|
|
Create your own custom dialog class that inherits FileDialog [^].
Use the best guess
|
|
|
|