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
FileId |
PortalId |
FileName |
Extension |
Size |
Width |
Height |
ContentType |
FolderID |
Folder |
StorageLocation |
IsCached |
1 |
0 |
aspdotnetstorefront.gif |
gif |
4177 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
2 |
0 |
aspnet.gif |
gif |
2965 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
3 |
0 |
community_icon.gif |
gif |
1666 |
77 |
54 |
image/gif |
19 |
|
0 |
False |
4 |
0 |
community_title.gif |
gif |
2190 |
170 |
33 |
image/gif |
19 |
|
0 |
False |
5 |
0 |
conferences_icon.gif |
gif |
1510 |
77 |
54 |
image/gif |
19 |
|
0 |
False |
6 |
0 |
conferences_title.gif |
gif |
2630 |
170 |
33 |
image/gif |
19 |
|
0 |
False |
7 |
0 |
crystaltech.jpg |
jpg |
6520 |
120 |
60 |
image/jpeg |
19 |
|
0 |
False |
8 |
0 |
datasprings.gif |
gif |
5613 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
9 |
0 |
dnn_large_banner.jpg |
jpg |
66633 |
890 |
341 |
image/jpeg |
19 |
|
0 |
False |
10 |
0 |
easycgi.gif |
gif |
5665 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
11 |
0 |
exacttarget.gif |
gif |
1001 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
12 |
0 |
item_bt_bg.gif |
gif |
1234 |
170 |
32 |
image/gif |
19 |
|
0 |
False |
13 |
0 |
itembg.gif |
gif |
225 |
170 |
2 |
image/gif |
19 |
|
0 |
False |
14 |
0 |
logo.gif |
gif |
3632 |
279 |
86 |
image/gif |
19 |
|
0 |
False |
15 |
0 |
marketplace_icon.gif |
gif |
1606 |
77 |
54 |
image/gif |
19 |
|
0 |
False |
16 |
0 |
marketplace_title.gif |
gif |
2626 |
170 |
33 |
image/gif |
19 |
|
0 |
False |
17 |
0 |
maximumasp.gif |
gif |
2016 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
18 |
0 |
portal.css |
css |
2770 |
|
|
application/octet-stream |
19 |
|
0 |
False |
19 |
0 |
support_icon.gif |
gif |
1668 |
77 |
54 |
image/gif |
19 |
|
0 |
False |
20 |
0 |
support_title.gif |
gif |
2048 |
170 |
33 |
image/gif |
19 |
|
0 |
False |
21 |
0 |
telerik.gif |
gif |
1193 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
22 |
0 |
training_icon.gif |
gif |
1693 |
77 |
54 |
image/gif |
19 |
|
0 |
False |
23 |
0 |
training_title.gif |
gif |
2100 |
170 |
33 |
image/gif |
19 |
|
0 |
False |
24 |
0 |
websecurestores.gif |
gif |
1375 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
25 |
0 |
windowslive.gif |
gif |
3262 |
120 |
60 |
image/gif |
19 |
|
0 |
False |
26 |
0 |
dbrc_home.css |
css |
16154 |
|
|
application/octet-stream |
19 |
|
0 |
False |
27 |
0 |
base.css |
css |
27699 |
|
|
application/octet-stream |
19 |
|
0 |
False |
28 |
|
default.css |
css |
18213 |
|
|
application/octet-stream |
1 |
|
0 |
False |
29 |
|
portal.css |
css |
3122 |
|
|
application/octet-stream |
1 |
|
0 |
False |
30 |
0 |
my-profile.png |
png |
15481 |
158 |
83 |
application/octet-stream |
19 |
|
0 |
False |
|
any help would be appreciated