freelanceprogrammers.org Forum Index » ASP

file transfer from one server to other server in asp.net????


View user's profile Post To page top
nju76@... Posted: Fri Sep 09, 2005 4:33 pm


Joined: 08 Sep 2005

Posts: 2
file transfer from one server to other server in asp.net????
hi..

I want to transfer file from one server to other server with asp.net..
i dont know exactly but perhapes it may be done by webclient class
of asp.net but how can i do it ??

if u have any idea abt this then pls reply me soon....

thanks..

bye...


---------------------------------
Yahoo! India Matrimony: Find your partner now.

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
kk_chamoli Posted: Fri Sep 09, 2005 5:38 pm


Joined: 05 Sep 2005

Posts: 3
file transfer from one server to other server in asp.net????
Hi,

Here I am writing some code see it if u find any difficulty, let me know.
Although I am using same code to save file from one web server to another

##### Coding in Source Web Server( Say Source) From Where File has been uploaded
#####
> Write this code on button click.
> Include required namespace i.e. System.Net
try
{
try
{
string strAddress = "http://localhost/Destination/frmUpload.aspx";
string fileName = "C:\Test.txt";
WebClient oClient = new WebClient();
oClient.UploadFile (strAddress,"POST",fileName);
}
catch(Exception exp) { throw exp; }
}
catch(Exception Exp)
{
Response.Write(Exp.Message);
}

##### Coding in Destination Web Server (Say Destination ) where file has to be
copied #####
Create a web form named frmUpload.aspx and on the Page_Load write following code
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["licid"] != null)
{
string VarLicId = Request.QueryString["licid"].ToString();
string strServerPath = "";
// Note: Write Destination directory name where file has to be copied (say
upload)

strServerPath = Server.MapPath("upload")
string[] strFiles = Directory.GetFiles(strServerPath);
int varCount = strFiles.GetUpperBound(0) + 1;
varCount++;
string FileName = "File_" + varCount.ToString() + ".xml";
// Put user code to initialize the page here
foreach(string f in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[f];
// Check File Exists or Not
if (File.Exists(strServerPath + "\" + FileName))
File.Delete(strServerPath + "\" + FileName);
file.SaveAs(strServerPath + "\" + FileName);
}
}
}
}

Please let me know whether this code fulfill your requirement or not
Regards

Krishan Kant


nidhi upadhyay <nju76@...> wrote:
hi..

I want to transfer file from one server to other server with asp.net..
i dont know exactly but perhapes it may be done by webclient class
of asp.net but how can i do it ??

if u have any idea abt this then pls reply me soon....

thanks..

bye...


---------------------------------
Yahoo! India Matrimony: Find your partner now.

[Non-text portions of this message have been removed]



SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language

---------------------------------
YAHOO! GROUPS LINKS


Visit your group "AspNetAnyQuestionIsOk" on the web.

To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


---------------------------------




--------------------------------------------------------------------
Krishan Kant Chamoli Office: +91-172-2653886
AutherGen Technology (P) Ltd., Fax: +91-172-5018485
24/3, Industrial Area, Phase - 2, Mobile: 9888263726
Chandigarh. INDIA. Pin - 160002. Email: kkchamoli@...

--------------------------------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
upadhyaynidhi@... Posted: Sat Sep 10, 2005 11:07 pm


Joined: 07 Sep 2005

Posts: 2
file transfer from one server to other server in asp.net????
hi..

Thanks for ur code...
I have some confusion...

-->I think in ur code u want to transfer file name
"Test.txt" to destination server..

u upload the file at one aspx page...means file is
uploaded on one aspx page??

-->ur code on destination web server...

string FileName="File_"+varCount.ToString() + ".xml";

so here u fixed one partiqular format of file
name??and why xml??

-->I cant understand ur following code..

*foreach(string f in Request.Files.AllKeys)
{

*if (File.Exists(strServerPath + "\" + FileName))
File.Delete(strServerPath + "\" + FileName);
file.SaveAs(strServerPath + "\" +
FileName);

thanks...
regards,
nidhi

--- krishan kant chamoli <kk_chamoli@...> wrote:

> Hi,
>
> Here I am writing some code see it if u find any
> difficulty, let me know. Although I am using same
> code to save file from one web server to another
>
> ##### Coding in Source Web Server( Say Source) From
> Where File has been uploaded #####
> > Write this code on button click.
> > Include required namespace i.e. System.Net
> try
> {
> try
> {
> string strAddress =
> "http://localhost/Destination/frmUpload.aspx";
> string fileName = "C:\Test.txt";
> WebClient oClient = new WebClient();
> oClient.UploadFile (strAddress,"POST",fileName);
> }
> catch(Exception exp) { throw exp; }
> }
> catch(Exception Exp)
> {
> Response.Write(Exp.Message);
> }
>
> ##### Coding in Destination Web Server (Say
> Destination ) where file has to be copied #####
> Create a web form named frmUpload.aspx and on the
> Page_Load write following code
> private void Page_Load(object sender,
> System.EventArgs e)
> {
> if (!IsPostBack)
> {
> if (Request.QueryString["licid"] != null)
> {
> string VarLicId =
> Request.QueryString["licid"].ToString();
> string strServerPath = "";
> // Note: Write Destination directory name where
> file has to be copied (say upload)
>
> strServerPath = Server.MapPath("upload")
> string[] strFiles =
> Directory.GetFiles(strServerPath);
> int varCount = strFiles.GetUpperBound(0) + 1;
> varCount++;
> string FileName = "File_" + varCount.ToString() +
> ".xml";
> // Put user code to initialize the page here
> foreach(string f in Request.Files.AllKeys)
> {
> HttpPostedFile file = Request.Files[f];
> // Check File Exists or Not
> if (File.Exists(strServerPath + "\" +
> FileName))
> File.Delete(strServerPath + "\" + FileName);
> file.SaveAs(strServerPath + "\" + FileName);
> }
> }
> }
> }
>
> Please let me know whether this code fulfill your
> requirement or not
> Regards
>
> Krishan Kant
>
>
> nidhi upadhyay <nju76@...> wrote:
> hi..
>
> I want to transfer file from one server to other
> server with asp.net..
> i dont know exactly but perhapes it may be done
> by webclient class
> of asp.net but how can i do it ??
>
> if u have any idea abt this then pls reply me
> soon....
>
> thanks..
>
> bye...
>
>
> ---------------------------------
> Yahoo! India Matrimony: Find your partner now.
>
> [Non-text portions of this message have been
> removed]
>
>
>
> SPONSORED LINKS
> Basic programming language Computer programming
> languages Programming languages Java programming
> language The history of computer programming
> language
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "AspNetAnyQuestionIsOk" on the
> web.
>
> To unsubscribe from this group, send an email
> to:
> AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the
> Yahoo! Terms of Service.
>
>
> ---------------------------------
>
>
>
>
>
--------------------------------------------------------------------
> Krishan Kant Chamoli Office:
> +91-172-2653886
> AutherGen Technology (P) Ltd., Fax:
> +91-172-5018485
> 24/3, Industrial Area, Phase - 2, Mobile:
> 9888263726
> Chandigarh. INDIA. Pin - 160002. Email:
> kkchamoli@...
>
>
--------------------------------------------------------------------
> Send instant messages to your online friends
> http://uk.messenger.yahoo.com
>
> [Non-text portions of this message have been
> removed]
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
kk_chamoli Posted: Mon Sep 12, 2005 9:51 am


Joined: 05 Sep 2005

Posts: 3
file transfer from one server to other server in asp.net????
Hi,
See, the code that I have written below, depends on following requirement. In
this code I have to send xml file from one server to another server. Since in my
project I have to concern with xml that`s why I am explicity give name name to
.xml extension.

Secondly u have written u unable to understand following code:
string FileName="File_"+varCount.ToString() + ".xml";

so here u fixed one partiqular format of file
name??and why xml??

-->I cant understand ur following code..

*foreach(string f in Request.Files.AllKeys)
{

*if (File.Exists(strServerPath + "\" + FileName))
File.Delete(strServerPath + "\" + FileName);
file.SaveAs(strServerPath + "\" +
FileName);

The SaveAs Method give an error if file with same name already exists in the
directory. So, I will assign unique name to each file. For that firstly I have
checked the no of file exists in the directory and according assign name to each
and every file. e.g. file1.txt, file2.doc. And as u said I am using I am using
only one format answer is no. This code upload file with any format. But
condition is that u must check file with same name if already exist it will give
error.

Anyway, If u found any problem u may chat with me my msn id
kk_chamoli@... and yahoo id kk_chamoli@... . I am right now online
in msn

Bye

Krishan Kant









Nidhi Upadhyay <upadhyaynidhi@...> wrote:

hi..

Thanks for ur code...
I have some confusion...

-->I think in ur code u want to transfer file name
"Test.txt" to destination server..

u upload the file at one aspx page...means file is
uploaded on one aspx page??

-->ur code on destination web server...

string FileName="File_"+varCount.ToString() + ".xml";

so here u fixed one partiqular format of file
name??and why xml??

-->I cant understand ur following code..

*foreach(string f in Request.Files.AllKeys)
{

*if (File.Exists(strServerPath + "\" + FileName))
File.Delete(strServerPath + "\" + FileName);
file.SaveAs(strServerPath + "\" +
FileName);

thanks...
regards,
nidhi

--- krishan kant chamoli <kk_chamoli@...> wrote:

> Hi,
>
> Here I am writing some code see it if u find any
> difficulty, let me know. Although I am using same
> code to save file from one web server to another
>
> ##### Coding in Source Web Server( Say Source) From
> Where File has been uploaded #####
> > Write this code on button click.
> > Include required namespace i.e. System.Net
> try
> {
> try
> {
> string strAddress =
> "http://localhost/Destination/frmUpload.aspx";
> string fileName = "C:\Test.txt";
> WebClient oClient = new WebClient();
> oClient.UploadFile (strAddress,"POST",fileName);
> }
> catch(Exception exp) { throw exp; }
> }
> catch(Exception Exp)
> {
> Response.Write(Exp.Message);
> }
>
> ##### Coding in Destination Web Server (Say
> Destination ) where file has to be copied #####
> Create a web form named frmUpload.aspx and on the
> Page_Load write following code
> private void Page_Load(object sender,
> System.EventArgs e)
> {
> if (!IsPostBack)
> {
> if (Request.QueryString["licid"] != null)
> {
> string VarLicId =
> Request.QueryString["licid"].ToString();
> string strServerPath = "";
> // Note: Write Destination directory name where
> file has to be copied (say upload)
>
> strServerPath = Server.MapPath("upload")
> string[] strFiles =
> Directory.GetFiles(strServerPath);
> int varCount = strFiles.GetUpperBound(0) + 1;
> varCount++;
> string FileName = "File_" + varCount.ToString() +
> ".xml";
> // Put user code to initialize the page here
> foreach(string f in Request.Files.AllKeys)
> {
> HttpPostedFile file = Request.Files[f];
> // Check File Exists or Not
> if (File.Exists(strServerPath + "\" +
> FileName))
> File.Delete(strServerPath + "\" + FileName);
> file.SaveAs(strServerPath + "\" + FileName);
> }
> }
> }
> }
>
> Please let me know whether this code fulfill your
> requirement or not
> Regards
>
> Krishan Kant
>
>
> nidhi upadhyay <nju76@...> wrote:
> hi..
>
> I want to transfer file from one server to other
> server with asp.net..
> i dont know exactly but perhapes it may be done
> by webclient class
> of asp.net but how can i do it ??
>
> if u have any idea abt this then pls reply me
> soon....
>
> thanks..
>
> bye...
>
>
> ---------------------------------
> Yahoo! India Matrimony: Find your partner now.
>
> [Non-text portions of this message have been
> removed]
>
>
>
> SPONSORED LINKS
> Basic programming language Computer programming
> languages Programming languages Java programming
> language The history of computer programming
> language
>
> ---------------------------------
> YAHOO! GROUPS LINKS
>
>
> Visit your group "AspNetAnyQuestionIsOk" on the
> web.
>
> To unsubscribe from this group, send an email
> to:
> AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the
> Yahoo! Terms of Service.
>
>
> ---------------------------------
>
>
>
>
>
--------------------------------------------------------------------
> Krishan Kant Chamoli Office:
> +91-172-2653886
> AutherGen Technology (P) Ltd., Fax:
> +91-172-5018485
> 24/3, Industrial Area, Phase - 2, Mobile:
> 9888263726
> Chandigarh. INDIA. Pin - 160002. Email:
> kkchamoli@...
>
>
--------------------------------------------------------------------
> Send instant messages to your online friends
> http://uk.messenger.yahoo.com
>
> [Non-text portions of this message have been
> removed]
>
>


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com





SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language

---------------------------------
YAHOO! GROUPS LINKS


Visit your group "AspNetAnyQuestionIsOk" on the web.

To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


---------------------------------




--------------------------------------------------------------------
Krishan Kant Chamoli Office: +91-172-2653886
AutherGen Technology (P) Ltd., Fax: +91-172-5018485
24/3, Industrial Area, Phase - 2, Mobile: 9888263726
Chandigarh. INDIA. Pin - 160002. Email: kkchamoli@...

--------------------------------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
e_arindam Posted: Mon Sep 12, 2005 11:36 am


Joined: 09 Jan 2006

Posts: 17
file transfer from one server to other server in asp.net????
Hi Champs,
I want whenever page is loaded, it should show all fresh information,
like if user click on browser back button, then also it should get info from
server. (In Asp.net)

Regards
Arindam



Arindam Chakraborty
Software Developer,
Mumbai,
India





---------------------------------
Yahoo! India Matrimony: Find your partner now.

[Non-text portions of this message have been removed]
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
English Courses in England - reservation calendar script
Land Surveying -Stonex instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help