|
Are you getting a compiler error or a runtime error? The method should look like this:
private static List GetMachinesDirectoryList()
{
string[] drives = Directory.GetLogicalDrives();
return new List<string>(drives);
}
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
using it in a private didn't work for me .. its working now that its in a public method.
weird.
Jammer
Going where everyone here has gone before!
|
|
|
|
|
System.IO.Directory.GetLogicalDrives(), I believe. Your problem is probably that the example assumes a using statement.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Did you get that issue with the BitmapSource sorted out?
|
|
|
|
|
I Pete,
I can't remember that particular issue! There have been so many lately they are all blurring into one mass of "eh?" heh heh ...
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Hi,
if you feel you are running from one problem to the next, and not gaining much
insight in the process, I strongly recommend you go to a book store, look into
some introductory or tutorial programming books, and choose and buy and study one,
chapter by chapter. That will teach you the basics in a logical order, provide
examples and show the right way to do things.
I am not going to recommend a specific book, since I believe it very much depends
on your programming knowledge in general and the writing style you prefer.
I do like most Microsoft books so far.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Sound advice. I think I'm picking up a lot of stuff fairly quickly. A lot of the time it also comes down to confidence. I have too often already quickly based a mail out on codeproject only to fix the problem seconds later.
I'm currently reading up on WPF and XAML/Blend/Expression as that is what I'm working with at the day job at the moment.
I think I'm doing okish. I've got to the point with my app in 1 month that took 6 months in FoxPro.
Code Project has been incredibly helpful.
Jammer
Going where everyone here has gone before!
|
|
|
|
|
Jammer wrote: Code Project has been incredibly helpful
Yes, it is a great community, and most threads converge to useful info.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Jammer - sorry about that. My OT was actually aimed at Christian, but there are good points between you and Luc.
|
|
|
|
|
Gotcha! I was racking my addled brain trying to think of what you might be referring too with that one.
haha ... there have been so very many issues!
Regards,
Jammer
Going where everyone here has gone before!
|
|
|
|
|
I have a method that convert a number to a letters created with c#.net.
if i wanna use this methodin excel so when someone insert a number in a cells in excel i wanna to load directly the letters corresponding to this number in the other cell.
Some one tell me to use the macros.
But i don't know how to use them. is there any help?????
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Not a C# question, unless C# runs inside Excel now ? I think VBScript is what runs inside Office apps.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: I think VBScript is what runs inside Office apps.
Nope. VBA.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Potayto - potahto :P
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello you. My name is saIam, am working on a window application on C#, the application is to get records of orders from a sales point and package the orders for the day after closure, then send as an email to the manager who works in a seperate office or might even be out of town just to enable him keep track of the daily sales at various stores. i have modelled the application but could not get the mailing aspect right just couldnt the config right .please need help on setting and configuring mail in window application with c#. Many thanks in anticipation.
stay jacking
|
|
|
|
|
What do you mean by 'config' ? You're failing to set a proper SMTP server ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes
fine, you msut give smtp server name ,port ,username ,password and etc.
this is way, please use the Appconfig file add all ur attributes.
after you can access by the configuration class in .net.
thanks
|
|
|
|
|
Forgive my dull C# questions, but I am a sometimes programmer needing to get up to speed very quickly:
1) Want to dynamically rename a variable within the loop, as in
AltChunkpart#
would become
altChunkpart1
altChunkpart2
etc.
2) Similarly, but it seems to be a special URI-specific case to be part of this line:
Uri uri# = new Uri("/programDescription#.txt", UriKind.Relative);
Uri uri#
would become
Uri uri1
Uri uri2
etc.
Failing to increment the 'uri' within the loop produces this error: "A local variable named 'uri' cannot be declared in this scope because it would give a different meaning to 'uri', which is already used in a 'parent or current' scope to denote something else"
Any guidance will be sincerely appreciated.
Jogannon
|
|
|
|
|
1 - can't be done. Instead, make an array and put that ending digit as the index into the array
2 - can't be done.
Your overall issue is that you have something like this:
Uri uri
for(whateveR)
{
Uri uri;
}
The second Uri can't have the same name as one in the higher scope. Just use a different name, it doesn't need to be different on each iteration, it just needs to be different than the name of the variable it would otherwise hide. Or, just use the same one, if the value does not matter in the higher scope.
string s = "one";
for(whateveR)
{
s = "two";
}
// now s == "two"
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks Christian. Great explanation. Now let me go and try to apply it.
Jogannon
|
|
|
|
|
Christian,
I am sorry to be so thick, however I understand the underlying need to have unique variable names. It is a matter of how does s == "two"? I do not see any counting or incrementing code in your example. My own approach (which fails) is to try and append (or concatenate an incrementing int value to the string name. Should I avoid this approach and go with a string array technique instead. Any concrete example will really help at this point.
Thanks,
Jogannon
|
|
|
|
|
"one" and "two" were arbitrary examples - the point was simply that the value given to the variable inside the second scope, applied to the first scope, too. I was illustrating that in your instance, you have a variable named uri in the outer scope, and so you couldn't create one with the same name in the inner scope, and if you reused the outer scope one to keep the same name, you would find that setting it, changed it for the outer scope.
Wow, now I'm confused
I was showing that if you used uri where you were putting Uri uri and getting the error, you would have flow on effects.
If you need to keep the variables you wanted to name uri1, uri2, etc for any reason, a list or array is the way to do that. If you were creating a variable for loop processing that is not reused, then just use a different name, like uriLoop or something.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks again, Christian. Let me go and work on this.
Jogannon
|
|
|
|
|
Member 2789142 wrote: it seems to be a special URI-specific case to be part of this line
no, its not uri specific. you try to declare the variable named "uri" multiple times, which is not allowed in this case.
int myInt = 0;
foreach (object obj in objList)
{
int myInt = 4;
}
|
|
|
|
|
I need to indicate that WinForms DataGridView column in sorted.
If column width is too small, sort glyph is not displayed.
Is it possible to force sorth glyph to display in narrow columns also or any other idea how to indicate that column is sorted?
I tried also to underline column caption in mouseclick event but this fails also.
I tried
foreach (DataGridViewColumn dataGridViewColumn in grid.Columns) {<br />
DataGridViewCellStyle dgvcellStyle = new DataGridViewCellStyle();<br />
System.Drawing.Font font = new System.Drawing.Font( <br />
dataGridViewColumn.HeaderCell.Style.Font,<br />
System.Drawing.FontStyle.Underline );<br />
dgvcellStyle.Font = font;<br />
dataGridViewColumn.HeaderCell.Style = dgvcellStyle;<br />
}
But got exception probably since debugger shows that
dataGridViewColumn.HeaderCell.Style.Font
is null.
dataGridViewColumn.HeaderCell.Style is not null.
How to fix ?
Andrus
|
|
|
|