PC Review


Reply
Thread Tools Rate Thread

Access to the path is denied.

 
 
Santosh
Guest
Posts: n/a
 
      16th Oct 2006
Hii i am writting following code for attaching file to the emails it
runs well on the local server but when i run it on domain servert then
it gives an error Access to the path is denied.
can any one tell me what is the problem in it.

public void AttachFilesToEmail(object sender, System.EventArgs e)
{
DataTable dt;
dt = attachedFileTable();
string strFile_Name;
int attachFile_Length;

//if(attachFile_Length==1
if (attachFile1.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile1.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile1.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile2.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile2.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile2.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile3.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile3.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile3.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}

}
if (attachFile4.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile4.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile4.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}
if (attachFile5.PostedFile.ContentLength > 0)
{
HttpPostedFile attFile1 = attachFile5.PostedFile;
attachFile_Length = attFile1.ContentLength;
if (attachFile_Length > 0)
{
strFile_Name = Path.GetFileName(attachFile5.PostedFile.FileName);
attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
dt =
addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
" Bytes");
}
}

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      16th Oct 2006
If I can take a guess, you are developing on Windows XP and deploying to
Windows Server 2003. The file you are attempting to attach exists in a
folder outside of the website (instead of something like <root>/attachments
it is c:\attachments).

If so, you have choices:
1. Turn off the transversal security bits and allow the website to read from
any folder (this is also known as "destroy the security of your machine")
2. Set up a windows service to feed the file
3. Move the attachment files to the website directory structure
4. Move the attachment "file" to the database

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"Santosh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hii i am writting following code for attaching file to the emails it
> runs well on the local server but when i run it on domain servert then
> it gives an error Access to the path is denied.
> can any one tell me what is the problem in it.
>
> public void AttachFilesToEmail(object sender, System.EventArgs e)
> {
> DataTable dt;
> dt = attachedFileTable();
> string strFile_Name;
> int attachFile_Length;
>
> //if(attachFile_Length==1
> if (attachFile1.PostedFile.ContentLength > 0)
> {
> HttpPostedFile attFile1 = attachFile1.PostedFile;
> attachFile_Length = attFile1.ContentLength;
> if (attachFile_Length > 0)
> {
> strFile_Name = Path.GetFileName(attachFile1.PostedFile.FileName);
> attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
> dt =
> addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
> " Bytes");
> }
> }
> if (attachFile2.PostedFile.ContentLength > 0)
> {
> HttpPostedFile attFile1 = attachFile2.PostedFile;
> attachFile_Length = attFile1.ContentLength;
> if (attachFile_Length > 0)
> {
> strFile_Name = Path.GetFileName(attachFile2.PostedFile.FileName);
> attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
> dt =
> addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
> " Bytes");
> }
> }
> if (attachFile3.PostedFile.ContentLength > 0)
> {
> HttpPostedFile attFile1 = attachFile3.PostedFile;
> attachFile_Length = attFile1.ContentLength;
> if (attachFile_Length > 0)
> {
> strFile_Name = Path.GetFileName(attachFile3.PostedFile.FileName);
> attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
> dt =
> addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
> " Bytes");
> }
>
> }
> if (attachFile4.PostedFile.ContentLength > 0)
> {
> HttpPostedFile attFile1 = attachFile4.PostedFile;
> attachFile_Length = attFile1.ContentLength;
> if (attachFile_Length > 0)
> {
> strFile_Name = Path.GetFileName(attachFile4.PostedFile.FileName);
> attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
> dt =
> addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
> " Bytes");
> }
> }
> if (attachFile5.PostedFile.ContentLength > 0)
> {
> HttpPostedFile attFile1 = attachFile5.PostedFile;
> attachFile_Length = attFile1.ContentLength;
> if (attachFile_Length > 0)
> {
> strFile_Name = Path.GetFileName(attachFile5.PostedFile.FileName);
> attachFile1.PostedFile.SaveAs(Server.MapPath(strFile_Name));
> dt =
> addmyRow(dt,strFile_Name,Convert.ToInt32(attachFile_Length).ToString()+
> " Bytes");
> }
> }
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to Path Denied Martin Microsoft C# .NET 2 5th Sep 2008 01:35 AM
An exception occurred in the OnBeforeInstall event handler of <name> Access to the path <path> is denied. Andrzej Lipski Microsoft Dot NET 0 5th Oct 2007 04:24 PM
Access to path denied Cheryl Yaeger Microsoft Dot NET 1 23rd Nov 2006 07:34 AM
Access to the path .... is denied j_stus@hotmail.com Microsoft ASP .NET 3 23rd May 2006 04:10 PM
Access to the path .... is denied j_stus@hotmail.com Microsoft ASP .NET 11 12th May 2006 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:41 PM.