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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...FIle System IOFIle System IO
Previous
 
Next
New Post
3/10/2009 8:37 AM
 

I need help with programming against the dnn file system io.

This is what I have discovered so far...

To add a directory I needed to use the core microsoft .net api.  Once I created the folder, I then had to add it (again) through the dotnetnuke api for it to be recognized by dotnetnuke (4.9.1)

I manually added a file and it does not show up in the file list-- FileController.GetAllFiles(portalID);

here is the code:

                        try
                        {
                            int success;

                            DotNetNuke.Services.FileSystem.FileController myFileController = new FileController();
                            DotNetNuke.Services.FileSystem.FolderController myFolderController = new FolderController();
                            DotNetNuke.Services.FileSystem.FolderInfo myFolderInfo = null;

                            Dictionary<string, FolderInfo> myFolderInfos = myFolderController.GetFolders(this.PortalId);
                            if (myFolderInfos != null && myFolderInfos.Count > 0)
                            {
                                if (myFolderInfos.ContainsKey("ProfileImages/"))
                                {
                                    myFolderInfo = myFolderInfos["ProfileImages/"];
                                }
                            }
                            if (myFolderInfo == null)
                            {

                                try
                                {
                                    if (!Directory.Exists(Server.MapPath("~/Portals/0/ProfileImages")))
                                    {

                                        Directory.CreateDirectory(Server.MapPath("~/Portals/0/ProfileImages"));
                                        success = myFolderController.AddFolder(this.PortalId, "ProfileImages");
                                    }
                                }
                                catch (IOException ioe)
                                {

                                }
                               
                                myFolderInfos = myFolderController.GetFolders(this.PortalId);
                                if (myFolderInfos != null && myFolderInfos.Count > 0)
                                {
                                    if (myFolderInfos.ContainsKey("ProfileImages/"))
                                    {
                                        myFolderInfo = myFolderInfos["ProfileImages/"];
                                    }
                                }

                            }
                            if (myFolderInfo != null)
                            {

                                DataTable myfiles = myFileController.GetAllFiles();
                               if (myfiles != null && myfiles.Rows.Count > 0)
                                {
                                    MyFiles.DataSource = myfiles;
                                    MyFiles.DataBind();
                                }
                            }
                        }
                        catch (Exception innerE) { }


                    }
                    catch { }

The folder now exists on my system with one image in it.  FolderID is 27, PortalID is 0, StorageLocation is 0

Here is a screen shot of the results

 

 

any help would be appreciated

 

 

 
New Post
3/10/2009 9:28 AM
 

you need to use the methods in dotnenuke.services.filesystemutils as well as files and folders classes, there is an add folder method which also adds the folder entry to the folders table.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
3/10/2009 10:44 AM
 

Note also that the shared method FileSystemUtils.AddFolder will both create the physical folder and add the appropriate entry to the DNN Folders table.

If you are saving a file that you have uploaded using an HttpFileUpload control, you may also want to consider using the shared method FileSystemUtils.UploadFile to both save the physical file and add the appropriate entry to the DNN Files table. Otherwise, you will have to use one of the AddFile methods on an instance of the FileController class to add the entry to the DNN Files table.

One other tip for you that I forget if I have not been working with the FolderController method for a while: all of the DNN methods in which a folder path is specified expect the path will end with a forward slash, for example "ProfileImages/"


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
11/10/2009 8:21 PM
 

Good last Tip William! There's a difference between "Templates/" and "/Templates". One throws an error, One loves it.

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...FIle System IOFIle System IO


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