473,327 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How do I pass a file to a class?

Sam
Hi,

I have a web form I use to allow users upload files to the web server.
Instead of handling this operation in the code behind of the web form, I
want to create a class that contains document management functions in it.
However, I don't know how to pass the file to this class. I'd appreciate
some pointers on how to do this.

Here's where I am stuck

public static int DumpFileOnWebServer( -- I don't know what goes in here --)
{
// Once I know how to pass the file to this class
// I can go ahead and handle the process in here i.e. where to put the
file, etc.
}

Thanks for your help.

Sam
Nov 15 '05 #1
3 1369
Sam,

You can pass an instance of the HttpFilesCollection class, which
contains the information about all of the files that were uploaded to your
page. This is exposed by the Files property on the HttpRequest class.
Because you might need extra information that is part of the request, you
might want to consider passing the HttpRequest itself, which would have all
of the information in it, or even the current HttpContext, which exposes the
Request, the Response, the Application, Server, etc, etc.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Sam" <sa*@globalwebcentral.com> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a web form I use to allow users upload files to the web server.
Instead of handling this operation in the code behind of the web form, I
want to create a class that contains document management functions in it.
However, I don't know how to pass the file to this class. I'd appreciate
some pointers on how to do this.

Here's where I am stuck

public static int DumpFileOnWebServer( -- I don't know what goes in here --) {
// Once I know how to pass the file to this class
// I can go ahead and handle the process in here i.e. where to put the
file, etc.
}

Thanks for your help.

Sam

Nov 15 '05 #2
Sam
Hi Nicholas,

Would you be nice enough to point to a code sample on a web site? Thank you
very much.
Sam
"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Sam,

You can pass an instance of the HttpFilesCollection class, which
contains the information about all of the files that were uploaded to your
page. This is exposed by the Files property on the HttpRequest class.
Because you might need extra information that is part of the request, you
might want to consider passing the HttpRequest itself, which would have all of the information in it, or even the current HttpContext, which exposes the Request, the Response, the Application, Server, etc, etc.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Sam" <sa*@globalwebcentral.com> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a web form I use to allow users upload files to the web server.
Instead of handling this operation in the code behind of the web form, I
want to create a class that contains document management functions in it. However, I don't know how to pass the file to this class. I'd appreciate
some pointers on how to do this.

Here's where I am stuck

public static int DumpFileOnWebServer( -- I don't know what goes in

here --)
{
// Once I know how to pass the file to this class
// I can go ahead and handle the process in here i.e. where to put the file, etc.
}

Thanks for your help.

Sam


Nov 15 '05 #3
Hi Sam, Nicholas,

I would do otherthing instead, I would upload the file using the code
behind and later provide this local file to the Doc. management layer.

You could upload the file to a temp file and later delete if needed.

Just my 2 cents :)

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Nicholas Paldino [.NET/C# MVP]" <ni**************@exisconsulting.com> wrote
in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Sam,

You can pass an instance of the HttpFilesCollection class, which
contains the information about all of the files that were uploaded to your
page. This is exposed by the Files property on the HttpRequest class.
Because you might need extra information that is part of the request, you
might want to consider passing the HttpRequest itself, which would have all of the information in it, or even the current HttpContext, which exposes the Request, the Response, the Application, Server, etc, etc.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- nick(dot)paldino=at=exisconsulting<dot>com

"Sam" <sa*@globalwebcentral.com> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a web form I use to allow users upload files to the web server.
Instead of handling this operation in the code behind of the web form, I
want to create a class that contains document management functions in it. However, I don't know how to pass the file to this class. I'd appreciate
some pointers on how to do this.

Here's where I am stuck

public static int DumpFileOnWebServer( -- I don't know what goes in

here --)
{
// Once I know how to pass the file to this class
// I can go ahead and handle the process in here i.e. where to put the file, etc.
}

Thanks for your help.

Sam


Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert | last post by:
Python doesn't know the class of a method when container not direct class attribute: >>> class X: .... def f():pass .... g=f .... l= .... >>> X.g <unbound method X.f>
1
by: Jonathan Gibbs | last post by:
I'm very new to xml, and struggling a bit.. I want to use an .xsd file passed to a windows application to define a dataset's schema, and also (if possible) pass other metadata associated with...
9
by: Jay Douglas | last post by:
Hello, I am needing to pass a class object (this) by reference to a method in a different class. When I do the following code I get the error (Cannot pass '<this>' as a ref or out argument because...
4
by: KC Eric | last post by:
Hi all, I have a dll file, it has a class, say: class Temp, this class has a function which has a delegate as a parameter, say: public void Test(GameOverHandler _overHandler)
2
by: kaushas | last post by:
All I have a file HTML object, I want to pass this object to a class so I can write a common method for uploading files. Idea is to avoid coding file saving in the forms submit button, but call a...
8
by: pcnate | last post by:
My class in a tech school, has kinda been debating over how you would get and pass data to a fuction in C++. What we would like to do is to pass information to a function directly from a cin...
6
by: kath | last post by:
hi everyone......... I have a task, I have fragmented the task into subtask. I have planned to create a class to each subclass and one parent class to handle the sub tasks. Each subclass are...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.