TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Yogesh Ghorpade
NA
762
148.9k
Error In Open Read Function While Uploading The File
Mar 17 2018 6:06 AM
File Path Not Getting Exactly
I Have Tried This Code
string fileExt = System.IO.Path.GetExtension(FileUpLoad1.FileName);
string fname = Path.GetFileName(FileUpLoad1.FileName);
string[] FileName = fname.Split(' ');
string sFileName = FileName[0] + ".pdf";
string filepath1 = Path.GetFilePath(FileUpLoad1.FileName);;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(HostName + "/" + strFtpFolder + sFileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(strUser, strPWD);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
StreamReader sourcestream = new StreamReader(FileUpLoad1.PostedFile.InputStream);
FileStream fs = File.OpenRead(filepath1)
byte[] filecontents = new byte[fs.Length];
request.ContentLength = filecontents.Length;
Stream requeststream = request.GetRequestStream();
requeststream.Write(filecontents, 0, filecontents.Length);
requeststream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
fs.Close();
response.Close();
//FileStream fs = File.OpenRead(Path.GetFullPath(FileUpLoad1.FileName));
//byte[] buffer = new byte[fs.Length];
//fs.Read(buffer, 0, buffer.Length);
//fs.Close();
//Stream ftpstream = request.GetRequestStream();
//ftpstream.Write(buffer, 0, buffer.Length);
//ftpstream.Close();
Reply
Answers (
1
)
Store value in database
like clr profiler like is any tool available to test asp.net