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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Open files from a custom moduleOpen files from a custom module
Previous
 
Next
New Post
11/13/2007 6:39 PM
 

I am designing a custom module in DotNetNuke using visual studio 2005 (VB). Users would be able to upload some files in different formats like .txt .jpeg .pdf and ... from the module and it works fine using the following code: 

FileUpload1.SaveAs(Server.MapPath("Portals\0\R226.txt"))

 

I also need to give them the option to open these files when they want and look at them or download them. I am using the following code which is working perfect when I run it on my local computer but when I upload the code to the server, it doesn't work. I appreciate for any recommendation. To make the code simple, I am using a specified file instead of using variables.

System.Diagnostics.Process.Start(Server.MapPath("Portals\0\R226.txt"))

it gives me the following error:

A critical error has occurred.
The system cannot find the file specified

Thanks,

Ali

 

 

 

 
New Post
11/13/2007 8:43 PM
 

When you're on the server, are you sure you're in Portal 0 and not another portal with a different ID?


Chris Hammond
Former DNN Corp Employee, MVP, Core Team Member, Trustee
Christoc.com Software Solutions DotNetNuke Module Development, Upgrades and consulting.
dnnCHAT.com a chat room for DotNetNuke discussions
 
New Post
11/14/2007 12:53 PM
 

Thanks Chris for replying.

I usually check it as the host user and I just checked with other users and it is the same. Since it works locally and not on the server, I think something is wrong with the path I am using however I expect that MapPath can find the right path.

Thanks again Chris,

Ali

 

 
New Post
11/14/2007 2:15 PM
 

In the code sample you posted, you're using a 'relative' path.

FileUpload1.SaveAs(Server.MapPath("Portals\0\R226.txt"))

will only work if the current folder on the web server at the time of execution is the home folder of your web site. While that may be true most of the time, I would suggest that you remove all chance of error and explicitly construct the path to your portal's root folder, then use Server.MapPath to convert it to a physical path.

PortalSettings has a property named 'HomeDirectory' that points to your portals folder, so in your example it would point to the /Portals/0 folder. To place the file in the root folder of the current portal ( in your case the portal with the ID of 0 )

Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
FileUpload1.SaveAs(Server.MapPath(_portalSettings.HomeDirectory & "R226.txt"))

The advantage of doing it this way is that if you have multiple portals and install your module in a portal other than the first portal ( for example a portal with an ID of 5 ), your module will still work.

 
New Post
11/14/2007 3:54 PM
 

 

Thanks Steve for your nice comment but My proble hasn't been solved yet.

The vb code I am using to open the file is "C:\Inetpub\wwwroot\rnlvn.com\wwwroot\DesktopModules\MyModule\MyVBCode.ascx.vb"

The file I am trying to open is "C:\Inetpub\wwwroot\rnlvn.com\wwwroot\Portals\0\R226.txt"

The line of Code I am using to open the file is: "System.Diagnostics.Process.Start(Server.MapPath("Portals\0\R226.txt")

Is there any idea why the file can not be opened and I keet getting this error that "The system cannot find the file specified" ?

Thanks

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Open files from a custom moduleOpen files from a custom module


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