|
I would have thought by now, with the other questions you have asked relating to this subject area, that you would know this is not easy to do.
You would have to hook into the system, and watch for all the file io operations.
|
|
|
|
|
I don't beieve that this information is logged anywhere. It would probably add quite an overhead to any OS. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Windows and NTFS do not track such information. There is no way to get it.
Even writing an NTFS extension wouldn't do anynthing for you since a copy operation is nothing more than "open a file and read it". There's no way to tell the difference between a file being copied and one being read by its application.
|
|
|
|
|
Thanks alot for sharing the information Best Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Yes it is Possible. You Should be work on Clipboard Hook. If you can think then I Can.
|
|
|
|
|
No, it's not. Clipboard won't give you the files that are dragged and dropped, nor will it give you anything done through a CMD prompt. Ever hear of XCOPY?
|
|
|
|
|
Yes
Clipboard not get the information regarding Dragged and Droped ,or Sendto method or Command Prompt .If you can think then I Can.
|
|
|
|
|
Hi all...
I am trying to format my pen drive by calling API SHFormatDrive function but it gives an error message.
I am using the following lines of code :
Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal iDrive As Long, ByVal iCapacity As Long, ByVal iFormatType As Long) As Long
Const SHFD_CAPACITY_DEFAULT = 0 'default drive capacity
Const SHFD_FORMAT_QUICK = 0 'Quick format.
Const SHFD_FORMAT_FULL = 1 'Full format.
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Try
Dim drvToFormat As Long = 6 '6 is the index of pendrive for G: drive.
Dim ret As Long
If chkQuickFormat.Checked Then 'Check for quick format.
ret = SHFormatDrive(Me.Handle.ToInt32, _
drvToFormat, _
SHFD_CAPACITY_DEFAULT, _
SHFD_FORMAT_QUICK)
Else
ret = SHFormatDrive(Me.Handle.ToInt32, _
drvToFormat, _
SHFD_CAPACITY_DEFAULT, _
SHFD_FORMAT_FULL)
End If
Select Case ret
Case -1
MsgBox("Error during format operation")
Case -2
MsgBox("Operation canceled by user")
Case -3
MsgBox("This drive cannot be formatted")
Case Else
MsgBox("Done")
End Select
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Sub
The above code is giving an error that "A call to PInvoke function 'SHFormatDrive' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."
I don't know exactly what is going wrong and when I am trying to format my pen drive, the above code is first checking for A: drive and then it is giving error.
Suggest me what should I do.
Thanks.
Gagan
|
|
|
|
|
Shouldn't the Me.Handle.ToInt32 be Me.Handle (a long?)
--edit--
PInvoke.net[^] claims that the signature should contain uint , not a long .I are Troll
modified on Sunday, March 7, 2010 6:48 AM
|
|
|
|
|
I tried Me.Handle.ToInt64 as it returns a long value but I still have the same error.
|
|
|
|
|
That would only pose a problem if the handle doesn't fit in a Int32 . Still, seems like the error you're getting is supported by the PInvoke.net claim; a uint isn't a long .I are Troll
|
|
|
|
|
Can you not just use My.Computer.FileSystem.Drives(x).DriveFormat() and keep it managed?
Ignore, i'm speaking pish!Dave
Don't forget to rate messages!Find Me On: Web| Facebook| Twitter| LinkedInWaving? dave.m.auld[at]googlewave.com
modified on Sunday, March 7, 2010 7:45 AM
|
|
|
|
|
daveauld wrote: My.Computer.FileSystem.Drives(x).DriveFormat()
Don't you know what it does? It only tells the drive format as FAT or NTFS and does not format the drive. I want to format my pen drive not to get its drive format name.
Gagan
|
|
|
|
|
Apologies misread the doc's, when i saw the FAT/NTFS, i thought that was the format options.
Note To Self: Don't skim read!
|
|
|
|
|
|
Gagan.20 wrote: Private Declare Function SHFormatDrive Lib "shell32" (ByVal hwnd As Long, ByVal iDrive As Long, ByVal iCapacity As Long, ByVal iFormatType As Long) As Long
You found and used a Declare for SHFormat that works with VB6, not VB.NET. Hint: Long in VB6 was a 32-bit signed Integer. Long in VB.NET is a 64-bit signed Integer.
|
|
|
|
|
When I am using the below code, it appears a Windows format window to format the drive.
<Runtime.InteropServices.DllImport("shell32.dll")> _
Private Shared Function SHFormatDrive(ByVal hwnd As IntPtr, ByVal drive As UInteger, ByVal fmtID As UInteger, ByVal options As UInteger) As UInteger
End Function
Public Enum SHFormatFlags As Integer
SHFMT_ID_DEFAULT = &HFFFF
SHFMT_OPT_FULL = &H1
SHFMT_OPT_SYSONLY = &H2
SHFMT_ERROR = &HFFFFFFFF
SHFMT_CANCEL = &HFFFFFFFE
SHFMT_NOFORMAT = &HFFFFFFD
End Enum
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Dim ret = SHFormatDrive(Me.Handle.ToInt64, _
drvToFormat, _
CUInt(SHFormatFlags.SHFMT_ID_DEFAULT), _
0)
msgbox(ret.tostring)
End Sub
It appears Windows format option to format the drive but I want that when I click on start button, it start formatting rather than displaying another window to format drive.
Tell me what should I do.
Thanks.
Gagan
|
|
|
|
|
You could use WMI to format the drive; see http://msdn.microsoft.com/en-us/library/aa390432(VS.85).aspx[^]
I don't have any sample code to share, you will have to do some digging yourself.
[Edit: this page says that it is supported on Server only, not Clients. I would imagine there is an equivalent somewhere that is supported.]
|
|
|
|
|
The WMI method you suggest to format drive is good but I've still some doubt. In this WMI method I do not understand that what drive it will format or what should I do to format a perticular drive.
Suggest me what should I do.
Thanks.
Gagan
|
|
|
|
|
This Format method of WMI is a member of a Volume object, therefore, it would format that particular volume.
Why don't you start with the link i gave you and work your way back up the WMI documentation, and you will see all sorts of classes and methods.
There are classes that enumerate the logical disk, volumes, drive types etc. etc.
There are examples scattered all over the place to do different things, so i guess a little bit of googling will eventually get you want you want.
|
|
|
|
|
I have a VBScript that uses WMI to format a drive. I got the code from some site but it is not formatting my pen drvie and giving error while executing the script.
The code is below:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'G:\\'")
For Each objVolume in colVolumes
errResult = objVolume.Format("NTFS")
Next
Here G: is my pen drive's drive name.
Suggest me how to format my pen drive.
Thanks.
Gagan
|
|
|
|
|
Hi all,
I am trying to copy a whole directory that contains files and subfolders. I have done a lot of searching on the web but I cannot find anything. I want to be able to show the progress of the copy in a progress bar. Sorry, I am new to vb.
Thanks
majan11
|
|
|
|
|
Hi,
welcome to CodeProject.
majan11 wrote: I am new to vb.
I hope that is VB.NET, not ancient VB which is unsupported and obsolete since a few years.
In .NET you would need these classes: Form, ProgressBar, DirectoryInfo, Directory, File, and maybe more. I suggest you read up on these; but maybe best is to study a book on VB.NET first, that will give you the fundamentals of the language and .NET programming in general.
|
|
|
|
|
Yes it is VB.NET. I will look into those classes you specified. Thanks
majan11
|
|
|
|
|
I've done something similar, involving copying a large number of files from one single folder into another. I started with a preliminary count of the number of files to be moved, then set the Maximum value of the progress bar to that number. Then, after copying each file, I incremented the progress bar value by one. The code looks like this:
AppMainForm.ProgressBarVisible = False
AppMainForm.ProgressBarMinimum = 1
AppMainForm.ProgressBarMaximum = Directory.GetFiles(ArchivePath).Length
AppMainForm.ProgressBarValue = 1
Dim DestPath As String = ""
For Each F As String In System.IO.Directory.GetFiles(ArchivePath)
If AppMainForm.ProgressBarVisible Then
AppMainForm.ProgressBarIncrement()
Else
AppMainForm.ProgressBarVisible = True
End If
DestPath = WebPath + System.IO.Path.GetFileName(F)
My.Computer.FileSystem.CopyFile(F, DestPath, True)
Next
AppMainForm is the MDI for the app, implemented as an interface; the progress bar is exposed as various properties and methods through the interface. The method ProgressBarIncrement simply adds 1 to the progress bar's value.
You should be able to modify this to allow for a recursive copy as well. At a guess, I would thing a two pass system might work, one to create the folder structure and one to copy the files. It might be visually interesting to implement two progress bars, one showing the copying of the current folder and one marking overall progress.
|
|
|
|