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 ExtensionsModulesModulesRenaming file error -System.IO.FileNotFoundExceptionRenaming file error -System.IO.FileNotFoundException
Previous
 
Next
New Post
4/22/2011 10:47 AM
 
Hi all. I have a custom module which works with no errors in my local machine but throws a "System.IO.FileNotFoundException" when the same module is ran on the website. The website is on a shared hosting with PowerDNN.  The error happens when I attempt to rename an image with a new name.  below is the code;
01.Public Sub CommitImages(ByVal tmpID As Integer, ByVal PostID As Integer, ByVal HomeDir As String)
02.           Dim aryTemps As ArrayList = getTempImages(tmpID, HomeDir)       
03.           Dim tImg As String
04.           For Each tImg In aryTemps
05.               Dim imgName As String = tImg.Substring(tImg.LastIndexOf("/") + 1)
06.               imgName = imgName.Substring(imgName.IndexOf("-") + 1)
07.               My.Computer.FileSystem.RenameFile(tImg, PostID & "-" & imgName)
08.           Next
09.          
10.       End Sub

The exact error I get is 'Could not find file 'C:\Portals\0\mmRentalListings\gallery\images\tmp3-buff.jpg'
The error happens on line 7. when I ftp to my site, I can see the image(s) exist. Again this method works on my local computer but not on my website. What gives? Is it because it's a shared hosting and I may not have access to C drive? If that's the case how should i do a rename?

thanks

Mackeny

pendelea.com -The #1 website for properties in Kenya
 
New Post
4/22/2011 11:40 AM
 
Mackeny

At the hosting your files located in the different folder then at your local machine. This is why you got error FileNotFound. You should use relative Paths from the PortalSettings. For example:

Me.PortalSettings.HomeDirectoryMapPath + NameOfYourFile

Hope this helps.

Sergey
 
New Post
4/22/2011 1:25 PM
 
Sergey Velichko wrote:
Mackeny

At the hosting your files located in the different folder then at your local machine. This is why you got error FileNotFound. You should use relative Paths from the PortalSettings. For example:

Me.PortalSettings.HomeDirectoryMapPath + NameOfYourFile

Hope this helps.

Sergey

 Sergey, that did the trick
I added

Inherits Entities.Modules.ModuleSettingsBase
to the class and then I changed line 7 to
My.Computer.FileSystem.RenameFile(Me.PortalSettings.HomeDirectoryMapPath & "mmRentalListings/gallery/images/tmp" & tmpID & "-" & imgName, PostID & "-" & imgName)

Thanks a lot


Mackeny

pendelea.com -The #1 website for properties in Kenya
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesRenaming file error -System.IO.FileNotFoundExceptionRenaming file error -System.IO.FileNotFoundException


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