Re: SHFileoperation question



Here's some routine i've used in a distributed application.

The move operation depends on the path.
If the path contains only a folder then you're moving a folder
If the path contains a filename, then you're moving a file etc...

As Igor mentioned, you need 2 nuls at end of paths.
( the method MoveFolder below adds the second. )


....
#include <string>
using namespace std ;
....

BOOL MoveFolder(string &from, string &to)
{
string f(from);
f+='\0';
string t(to);
t+='\0';

SHFILEOPSTRUCT fo;
ZeroMemory(&fo, sizeof(SHFILEOPSTRUCT));
fo.wFunc = FO_MOVE;
fo.pFrom = f.c_str();
fo.pTo = t.c_str();
fo.fFlags = FOF_SILENT|FOF_NOCONFIRMATION|FOF_NOCONFIRMMKDIR;

if( SHFileOperation(&fo) != 0 )
return FALSE;

return TRUE;
}


.



Relevant Pages

  • Re: Creating a new folder name based on user input to a text box
    ... Here is a routine I use in a lot of my programs. ... Dim NameofDir As String ... > folder specified by the user i.e. the folder name will be in the form, ...
    (microsoft.public.vb.general.discussion)
  • File Deletion Problem
    ... across volumes (i.e. moving a folder from drive C: to drive D:). ... everything works great with the copy routine. ... Sub DeleteDirectory(ByVal theSrcDir As String) ... Dim theDirList() As String = ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: how to determine if a directory exists
    ... /* validates existance of a folder using some different approaches ... parse arg folder ... string = strip ... ::routine remove_quotes ...
    (comp.lang.rexx)
  • Re: VB6 and Windows Media Player
    ... within the My Music Folder. ... Private Declare Function ShellExecute Lib "shell32.dll" Alias ... "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal ... the folder Documents and Settings eg:- C:\Documents and Settings? ...
    (microsoft.public.vb.general.discussion)
  • Re: File Input Question
    ... To have a user select a folder, not a file, I use the below. ... pszDisplayName As String 'Address of a buffer to receive the display name of the folder ... Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long ... Private Declare Function GetWindowRect Lib "user32" ...
    (microsoft.public.excel.programming)

Loading