|
PIEBALDconsult wrote: Isn't that just 1 ?
Theoretically, yes. With all the rounding errors in floating-point math, who knows, it could be slightly less and get truncated to zero...
Why make things simple when you can make them look highly scientific?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
at this time m chking with only 1 LED.
|
|
|
|
|
You might want to look into the shift-left operator anyway.
|
|
|
|
|
|
PIEBALDconsult wrote: Parallel Port
what is this parallel port you speak of?
is it that big connector I think I once saw in the Science Museum?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
No, no, parallel connectors are actually rather petite, a mere twenty-five pins.
|
|
|
|
|
This better way of getting 1.
value += (int)(Math.Pow(Math.Sin(3.2), 2) + Math.Pow(Math.Cos(3.2), 2) + (8 / Math.Floor(8.7)) - 1);
|
|
|
|
|
Hi,
I've a university issued laptop with windows 7 on it. When I click on "windows" button it show my name as one of the system folder, but there is no path for it. It is above the "My Document" folder, in fact everyone in the university has same folder with their name [obviously]. I want to make an program that could extract the name of this folder when its it run on a particular system. And computer name, account name or name of Environment.getFolderName(SpecialFolder.Personal) all are different from this folder. I do not know where is this folder even stored.
CHECK THIS LINK FOR AN IMAGE
http://dl.dropbox.com/u/10120092/Untitled.png[^]
SHIVAM
|
|
|
|
|
There isn't a direct way, this however should give what you want:
string s=Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
s=s.SubString(0, s.Length-8);
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Shivam (/Luc);
You can access this folder with the SpecialFolder UserProfile ;
String s = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
|
|
|
Only if using .NET framework V4
|
|
|
|
|
Well the OP did not make reference to any .Net version, i don't know what he is using
[at least he knows now it exists in later frameworks!)
|
|
|
|
|
True.
I've had a look in reflector and it's easy enough to do this in previous versions - see my other answer[^] below
|
|
|
|
|
Hi, nothing seems to work. I tried your way, it only shows some other folder on my desktop.
|
|
|
|
|
try to be specific. What have you tried and what was the outcome?
What operating system, which .NET version, what exactly do you get, what exactly would you like to get.
It works for me!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I tried your code.
I get "C:\Users\100xxxxxx\Desktop" where 100xxxxxx is my student ID.
I'm using .Net 3.5 but I do have .Net 4 with visual studios 10. Not why it is not working for me..
S
|
|
|
|
|
And is there a folder somewhere that holds your actual name instead of your student ID?
All GetFolderPath() results are actual folder names.
When a user account gets created, the user name displayed is also used as the folder name; it is however possible to change one without changing the other, as explained e.g. here[^]. I guess that is what happened to the student accounts: first create them numerically, then modify their display names. The display name of the current user should be available through Environment.UserName
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Very strange but I do not see this folder anywhere on my computer. It shows when I press windows button or when I'm choosing or opening some file. I tried Environment.UserName but it is showing my student ID [LOL]. Anyways thanks, I checked your link, probably this what happening in my case too. DAM IT, but there has to be some folder which starts with my name.
Shivam
|
|
|
|
|
You're welcome.
BTW: Most of the username/foldername magic is hidden in the registry, as the article explains.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
YUPPII. I solved the problem. I searched my name inside the registry and found that everyone is school has same registry key to that their name as registry value..so in my program I'm reading the registry value from this registry key..and it is working fine..thanks everyone again..
SHIVAM
|
|
|
|
|
As an alternative to Luc's suggestion you can combine the SystemDrive and HOMEPATH environment variables something like this:
public static string GetUserFolder()
{
return
Environment.GetEnvironmentVariable("SystemDrive") +
Environment.GetEnvironmentVariable("HOMEPATH");
}
Edit: Just tested from explorer and using Process.Start and it appears to work with only the HOMEPATH variable too
|
|
|
|
|
Having seen Dave's answer that it is available in v4, I've had a look at how it's done using reflector and these two functions combined perform the same task and will work with earlier .NET versions so long as it's run on a platform that supports it - if not, a PlatformNotSupportedException will be raised.
public const int UserProfile = 40;
[DllImport("shfolder.dll", CharSet = CharSet.Auto)]
private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
public static string GetUserPath()
{
StringBuilder resultBuilder = new StringBuilder(260);
int num = SHGetFolderPath(IntPtr.Zero, UserProfile, IntPtr.Zero, 0, resultBuilder);
if (num == -2146233031)
throw new PlatformNotSupportedException();
return resultBuilder.ToString();
}
|
|
|
|
|
I have been using C# and Visual Studio for about 6 months now and it has worked fine. Recently, I don't know what I did, but when I try to publish a program now it doesn't work properly. I have no build errors, but when I click on publish under the menu (or in the project window), it says "Could not publish because a project failed to build."
I searched for this online and found it can sometimes be caused by DevExpress. So, I uninstalled DevExpress, and I still get the problem.
I thought I might have done something clumsy in code, so I started a completely new solution, a windows form, and clicked publish. I still get the problem.
One thing I noticed is when I click publish, a "(name of project)TemporaryKey.pfx" appears in the project window, at about the same time the error happens. Could that maybe have something to do with my problem? (I know very little about keys.) Any ideas? Thanks for any help.
|
|
|
|
|
Just an idea. Maybe the key is automatically generated on the first publish. If that is the case, it may have an expiration date, say, one year after the initial build. If it is expired, perhaps that is what is causing the build to fail. Maybe try generating a new one?
Though, the fact that you had the same problem when creating a new project suggests that the problem is something else. I imagine you'd get a new temporary key when building a new project (assuming it is in a new solution).
|
|
|
|
|
Hello i have this problem.
I need to send a message from a child window to a parent window using sendmessage but i can't make it work to send the Size object to my lParam parameter and i don't know how to cast it when catching it in the parent window so i get the valid Size object i send can someone tell me how?
i am getting Cannot convert type 'System.Drawing.Size' to 'int' when calling sendmessage i don't know how to pass it there, thanks
|
|
|
|