Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am kinda new to MFC/OLE and whatnot.. I am stuck with IStream interface. I am trying to move files in a custom file system. Weirdly, when I try to move from one storage to another, it is instead creating a new file with the destination-storage pre-pended to the file name.

For example, if I am trying to move a file "xyz" in root to folder "temp", it is ending up re-naming xyz to tempxyz in the root folder instead of new path being temp/xyz.

Please help with what wrong with this piece of code :
C++
CComPtr<IUnknown> destinationStorage;
 GetStorage(newPath, &destinationStorage);
 IStoragePtr destinationFolder;
 destinationStorage->QueryInterface(__uuidof(IStoragePtr), (LPVOID*)&destinationFolder);
 CComPtr<IUnknown> sourceStorage;
 GetStorage(oldPath, &sourceStorage);
 IStoragePtr sourceFolder;
 sourceStorage->QueryInterface(__uuidof(IStoragePtr), (LPVOID*)&sourceFolder);
 HRESULT hr = sourceFolder->MoveElementTo(_bstr_t(oldFile), destinationFolder,
    _bstr_t(newFile), STGMOVE_MOVE);

GetStorage is a custom function and when I trace, both oldFile and newFile have SAME name and not the weird pre-prended name it ends up creating :|
Posted
Updated 20-Aug-10 7:34am
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900