|
The environment variable SYSTEMROOT will tell you where Windows is running from, or SYSTEMDRIVE will tell you the drive Windows is running from. Chec out the <a href="http://msdn2.microsoft.com/en-us/library/77zkk0b6(VS.80).aspx">Environment.GetEnvironmentVariable</a>[<a href="http://msdn2.microsoft.com/en-us/library/77zkk0b6(VS.80).aspx" target="_blank" title="New Window">^</a>] method to retrieve this value.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
Sub: How to find out the System BOOT Disk in Windows XP?
We have the Windows Application Developed by VB.NET.
Need: For Security purpose need to check one file in the Boot Drive.
Some Drive C: is the boot drive(Always).
Few Cases : Drive D or some one is the boot drive.
In this case how to find the System Boot Disk?
(Enviornment varible helps to find the System or Current Direcries)
In VB.NET Coding or any another way please let me know?
Advance Thanks
Anandan k
|
|
|
|
|
hi,
i wrote one vb.net service which checks for a set of conditions. if the condition fails, it gives a warning to the user asking him to fulfil the conditions within 30 minutes, failing which he will be forcebly logged off. after 30 mins, it checks taht condition again & does accordingly. (i used a msgbox to give that warning to the user).
it works well & good if he responds to the msgbox by clicking on it. if he doesn't respond at all, it throws an error saying that service cannot run & stops abruptly. i guess it is waiting for the user's response for that msgbox.
i am thinking of two options:
some other way (popup kind) to give warning to the user instaed of msgbox
start a separate thread for this kind of messages
i will be thankful for some light on these issues & a better solution.
|
|
|
|
|
It would help if you would display your code. But I'm thinking that you should use a Try Catch statement.
|
|
|
|
|
Hey everyone, well the title says it all. How do I delete all files in a folder? e.g. TEMP folder
PS: How would I display the results in a textbox of what is in that folder before i delete it? ( then i click a button to comfirm deletion)
|
|
|
|
|
Sadly, the answer is 'one at a time'. Directory.GetFiles will tell you the files, then you delete them one at a time.
SLRGrant wrote: PS: How would I display the results in a textbox of what is in that folder before i delete it?
Same way, show them what Directory.GetFiles returns, you can make that array of strings the datasource of a list control.
Christian Graus - C++ MVP
|
|
|
|
|
Christian Graus wrote: Sadly, the answer is 'one at a time'. Directory.GetFiles will tell you the files, then you delete them one at a time.
Does that mean that I couldnt create a program that could clean the computer like CCleaner for example?
|
|
|
|
|
No, of course not. Why would it mean that ?
Christian Graus - C++ MVP
|
|
|
|
|
|
If you want to delete all the files in a folder, the best approach would be to use a for/next statement. use a listbox for your display as oppose to a textbox.
Dim di as new system.io.directoryinfo = "your directory" '(1)
Dim fi as system.io.fileinfo
for each fi in di.getfiles'(5)
'(4)
listbox1.items.add(fi.filename)
fi.delete '(2) (3)
'(4)
next
Note:
(1) You could use a folder browser dialog to establish the folder or for the user to establish the folder
(2) When testing, have a test folder filled with copies files or something.
(3) If you wished to display first then give the option of deleting, you could put a similar for/next statement under a button's click action or something and only have delete option.
(4) You could have an if statement here for certain paremeters
(5) In the brackets after getfiles, you can specify file type
Posted by The ANZAC
|
|
|
|
|
Cool, well thanks guys for all your help, I will fiddle about with the code and see what the result is
|
|
|
|
|
I need to present an image file image in Access based on a 'file path and name' pointer in a database record. I am using OLE and I get one of two run-time error messages at the acOLECreateLink action. The first: (2793) "Microsoft Office Access can't perform the operation specified in the Action Property of the Visual Basic procedure you're trying to run." The second: (2786) "The OLE server doesn't support linking."
I can find nothing specific in the MSDN library. Help!
Michael J Wolfstone
It is always fun to learn new stuff!
|
|
|
|
|
When I use File.GetLastWriteTime(path) to get the date and time value of a file with a last write date of 5/8/2006 8:00a.m. the .NET 2.0 call always adds 1 to the hour so it ends up reading as 5/8/2006 9:00 a.m. How can I stop this? I need the file date to be read back exactly like the Windows explorer displays it.
|
|
|
|
|
Hi,
If the file is not on the same machine as the app, then you could check to see if the system time of both machines is set the same (especially daylight saving time).
Otherwise, if you are absolutely certain that it always adds exactly one hour you can use this:
CDate(File.GetLastWriteTime(path)).AddHours(-1)
Hope it helps,
Johan
|
|
|
|
|
No, the problem occurs because Win32 and .NET make different choices with regard to dealing with Daylight Saving Time.
For a discussion, see here:
http://blogs.msdn.com/oldnewthing/archive/2003/10/24/55413.aspx
To compensate, you have to adjust the time you use with SetLastWriteTime and GetLastWriteTime. When setting, adjust from .Net to Win32. When getting, adjust from Win32 to .NET. Here's some example code:
static DateTime AdjustTime_DotNetToWin32(DateTime time)
{
DateTime adjusted = time;
if (DateTime.Now.IsDaylightSavingTime() && !time.IsDaylightSavingTime())
adjusted = time - new System.TimeSpan(1, 0, 0);
else if (!DateTime.Now.IsDaylightSavingTime() && time.IsDaylightSavingTime())
adjusted = time + new System.TimeSpan(1, 0, 0);
return adjusted;
}
static DateTime AdjustTime_Win32ToDotNet(DateTime time)
{
DateTime adjusted = time;
if (DateTime.Now.IsDaylightSavingTime() && !time.IsDaylightSavingTime())
adjusted = time + new System.TimeSpan(1, 0, 0);
else if (!DateTime.Now.IsDaylightSavingTime() && time.IsDaylightSavingTime())
adjusted = time - new System.TimeSpan(1, 0, 0);
return adjusted;
}
void MySetLastWriteTime(String targetFile, DateTime t)
{
DateTime adjusted = AdjustTime_DotNetToWin32(t);
System.IO.File.SetLastWriteTime(targetFile, adjusted);
}
DateTime MyGetLastWriteTime(String targetFile)
{
DateTime t = System.IO.File.GetLastWriteTime(targetFile);
return AdjustTime_Win32ToDotNet(t);
}
|
|
|
|
|
Hi
I'm designing an interface with navigation bar ,, it's viewing my own control on the same form ,,, but i want to chech if the control is aleady viewed to prevent the user from open it more than one time ..
jooooo
|
|
|
|
|
Create a static variable, so it's visible across all instances of the control, and set it to true when the first one is shown. If it's true, don't allow more to be created.
Christian Graus - C++ MVP
|
|
|
|
|
|
*grin* not sure if I earned all of that, but sure glad to help.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have a CheckedListBox (CLB) on my form, the user can add, edit and remove items. I also have a context menu for the CLB that has the option to remove all checked items. What i need to know is how to structure a for next statement to cycle through and remove all checked items.
Posted by The ANZAC
|
|
|
|
|
For i As Integer = 0 To CLB.Items.Count - 1<br />
CLB.SetItemChecked(i, False)<br />
Next
|
|
|
|
|
Hey ANZAC,
I'm not sure if you mean remove the item or uncheck it, but if you want to remove an item try:
For i As Integer = YourCHB.CheckedIndices.Count - 1 To 0 Step -1
YourCHB.Items.RemoveAt(YourCHB.CheckedIndices.Item(i))
Next
The reason why I am using CheckedIndices is because when I give i to Item, it knows I want the checked item index rather than the general index.
I did think of using the GetEnumerator method on CheckedIndices and going through the collection that way, but because I modify the collection, it would stuff that up, which is why I'm going backwards because the positions are getting changed on each remove.
|
|
|
|
|
Thanks, i should have stated, i am trying to remove all of the checked items, this will probably work, but i figured it out anyways.
Dim C As Integer = clbList.Items.Count
If Me.clbList.CheckedIndices.Count > 0 Then
Do Until C = 0
If clbList.CheckedIndices.Contains(C) Then
clbList.Items.RemoveAt(C)
Me.clbList.SelectedIndex = 0
End If
C -= 1
Loop
If clbList.CheckedIndices.Contains(Me.clbList.SelectedIndex) Then
Me.clbList.Items.RemoveAt(Me.clbList.SelectedIndex)
End If
End If
This is my method, not as clean but i like it well enough.
Posted by The ANZAC
|
|
|
|
|
Hi!
Is there a way to draw line and bar chart on the same chart using AxMSCHART?
or
Is there a way to do paint both Bar and line graph on a PictureBox?
Or
Draw BarGraph on one Picturebox and Line on another picturebox,make one of them transparent so it would expose the other graph that is located right beneath.
|
|
|
|
|
If you want to do graphics programming, you need to forget about using picture boxes, so you can just draw it yourself.
Christian Graus - C++ MVP
|
|
|
|