Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesMove fileMove file
Previous
 
Next
New Post
1/27/2012 11:43 AM
 
Hi,

I want to move a file within a portal, e.g.
from "D:\DotNetNuke\Portals\1\MyOldFolder\abc.pdf"
to "D:\DotNetNuke\Portals\1\My\New\Folder\abc.pdf"

But
FileSystemUtils.MoveFile("MyOldFolder/abc.pdf", "My/New/Folder/abc.pdf", new PortalSettings(1));
does not work.

The folders exist and are synced, this is sure. The function above returns a string saying:
"startIndex cannot be larger than length of string.\r\nParameter name: startIndex"

Any ideas?

Best wishes from Innsbruck
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
1/27/2012 7:09 PM
 
at a glance it looks fine (though perhaps the path starts with / I can't recall) - however i'd recommend you run SELECT filename, folder FROM dbo.[Files] AS files where portalid=1 to see what the values are

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
1/28/2012 2:36 AM
 
Cathal,

thanks. The values are the same as before trying to move the files, in this example:

FileName = "abc.pdf"
Folder = "MyOldFolder/"
FolderID = xy

When I run
SELECT * FROM Folders WHERE FolderID = xy
the value in the FolderPath is "MyOldFolder/"

So nothing did change in the database, and the file is definitely not moved (also in the file system). When I start the path with a forward slash, I get some exception ("Input string not in the correct format").

Note: The string returned from the example above is not an exception. It is the return value of the FileSystemUtils.MoveFile(...) function. An exception is not fired.

Best wishes from Innsbruck
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
1/28/2012 5:31 AM
 
Got it!

The solution is you have to use the physical file paths as parameters. I did not think about this as the portal settings have to be passed to the function as well, but rememered something similar with the FileSystemUtils.AddFolder method (parent folder has to be passed in it's physical form).

Well, here is the working code:

FileSystemUtils.MoveFile("D:\\DotNetNuke\\Portals\\1\\MyOldFolder\\abc.pdf", "D:\\DotNetNuke\\Portals\\1\\My\\New\\Folder\\abc.pdf", new PortalSettings(1));

Hope it saves some time to investigate for someone in the future...

Best wishes from Innsbruck
Michael

Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesMove fileMove file


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out