473,396 Members | 1,804 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,396 software developers and data experts.

Transfering files between executables

What is the best way to transfer files between two .NET executables?
I have a service, and a client program. Client asks service for data. The
service creates one, and passes it back to client. Both programs run in .NET
framework.
Given this requirement, how best to approach the issue? Does .NET framework
provides any class that can help?
Thanks in advance,
Jul 21 '05 #1
7 1502
Do they have a common drive they can access? If so, you could just write
the file to disk and then let the service pick it up at scheduled intervals.

"Ravi J" <Ra***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
What is the best way to transfer files between two .NET executables?
I have a service, and a client program. Client asks service for data. The
service creates one, and passes it back to client. Both programs run in ..NET framework.
Given this requirement, how best to approach the issue? Does .NET framework provides any class that can help?
Thanks in advance,

Jul 21 '05 #2
Ravi

The other option is to stream the file from app to app over using sockets.
The file share is quicker id the app is for local use only. The socket
streaming might be good if the application is located on a separate server
to which the service do not have access too.

Henk

"Ravi J" <Ra***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
What is the best way to transfer files between two .NET executables?
I have a service, and a client program. Client asks service for data. The
service creates one, and passes it back to client. Both programs run in
.NET
framework.
Given this requirement, how best to approach the issue? Does .NET
framework
provides any class that can help?
Thanks in advance,

Jul 21 '05 #3
CMM
That's such an old school COBOL-esque way of doing things.

If you're transferring files between client/server via remothing you'd just
convert the filestream to a bytearray (code below) and return the contents.
If you're worried about first "loading the file into memory" or whatever...
consider this: this is pretty much exactly what the operating system does
even if you go the "polling" route suggested by others.

Dim fs As New System.IO.FileStream(theFile, IO.FileMode.Open,
IO.FileAccess.Read)
Dim bytes(CInt(fs.Length) - 1) As Byte '.length property is Long so it needs
to be cast
fs.Read(bytes, 0, CInt(fs.Length))
fs.Close()
Return bytes

then just reverse the process on the client side.

"Peter Rilling" wrote:
Do they have a common drive they can access? If so, you could just write
the file to disk and then let the service pick it up at scheduled intervals.

"Ravi J" <Ra***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
What is the best way to transfer files between two .NET executables?
I have a service, and a client program. Client asks service for data. The
service creates one, and passes it back to client. Both programs run in

..NET
framework.
Given this requirement, how best to approach the issue? Does .NET

framework
provides any class that can help?
Thanks in advance,


Jul 21 '05 #4
Thanks Henk, But sockets is ruled out for the time being. Both the client
and server needs to be on the same machine without touching sockets.
"Henk Verhoeven" <henk.verhoeven@_nospam_bluecod.net.nonospam> wrote in
message news:eg*************@TK2MSFTNGP10.phx.gbl...
Ravi

The other option is to stream the file from app to app over using sockets.
The file share is quicker id the app is for local use only. The socket
streaming might be good if the application is located on a separate server
to which the service do not have access too.

Henk

Jul 21 '05 #5
Thanks Peter and CMM.
Peter, I thought about using a shared drive, but then I don'treally need
..NEt framework for this. I am wondering if some sort of queue can be
established between client and the server where in the server keeps writing
in and the clients keep reading.
CMM, Thx for the code snippet, but I am a little confused. How does the
client establish a connection to the file stream that the server (or windows
service) is writing to?

Back in the COM days, you could invoke a COM component running inside a
service and still be able to communicate as if it were a simple local
object. Can something like that be done using .NET? One possibility I see is
somehow add a reference inside the client for the service and use the class.
Would that be possible? And also, how to impliment it if both client and the
service are running in seperate user account?

Again, thanks for your replies (past/advance)
Ravi
"CMM" <CM*@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
That's such an old school COBOL-esque way of doing things.

If you're transferring files between client/server via remothing you'd just convert the filestream to a bytearray (code below) and return the contents. If you're worried about first "loading the file into memory" or whatever... consider this: this is pretty much exactly what the operating system does
even if you go the "polling" route suggested by others.

Dim fs As New System.IO.FileStream(theFile, IO.FileMode.Open,
IO.FileAccess.Read)
Dim bytes(CInt(fs.Length) - 1) As Byte '.length property is Long so it needs to be cast
fs.Read(bytes, 0, CInt(fs.Length))
fs.Close()
Return bytes

then just reverse the process on the client side.

"Peter Rilling" wrote:
Do they have a common drive they can access? If so, you could just write the file to disk and then let the service pick it up at scheduled intervals.
"Ravi J" <Ra***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
What is the best way to transfer files between two .NET executables?
I have a service, and a client program. Client asks service for data. The service creates one, and passes it back to client. Both programs run
in ..NET
framework.
Given this requirement, how best to approach the issue? Does .NET

framework
provides any class that can help?
Thanks in advance,


Jul 21 '05 #6
CMM
AFAIK the only way to communicate between EXE's-- even on the same machine--
is via Remoting. It's not that hard.... just declare your classes as
ServicedComponent and register them on a channel. Check out this article for
some simple examples (that don't require IIS and stuff)
http://www.codeguru.com/Csharp/Cshar...icle.php/c5871.

In the COM world exe's could do this easily via SingleUse vs. MultiUse
classes. Even plain Win32 DLL's can do it (share variables) via #pragma
blocks. But in .NET this seems a little hard.

"Ravi J" wrote:
Thanks Henk, But sockets is ruled out for the time being. Both the client
and server needs to be on the same machine without touching sockets.
"Henk Verhoeven" <henk.verhoeven@_nospam_bluecod.net.nonospam> wrote in
message news:eg*************@TK2MSFTNGP10.phx.gbl...
Ravi

The other option is to stream the file from app to app over using sockets.
The file share is quicker id the app is for local use only. The socket
streaming might be good if the application is located on a separate server
to which the service do not have access too.

Henk


Jul 21 '05 #7
CMM
You'd need to study up on .NET Remoting... even if both exe's are on the same
machine. I think- if I understood your post correctly- that this is what
you're looking for. It's not difficult and it allows your exe to behave
similarly to a good ol' COM ActiveX EXE Server...

In the server EXE's Sub Main you'd do something like:
Dim TCPChannel As TcpChannel = New TcpChannel(49175) 'can be any port you want
ChannelServices.RegisterChannel(TCPChannel)
RemotingConfiguration.RegisterWellKnownServiceType (GetType(<YOURCLASS>),
"<SOME_NAME_TO_IDENTIFY_THIS_CONNECTION>", WellKnownObjectMode.SingleCall)

In the client you'd do something like this to call the exe:
Dim o As YOURCLASS = CType(Activator.GetObject(GetType(YOURCLASS),
"tcp://localhost:49175/<SOME_NAME_TO_IDENTIFY_THE_CONNECTION"), YOURCLASS)
'now use it like any ol' object
x = o.DoSomething()

Your class needs to inherit from MarshalByRef... and any types it returns
need to be serializable (most types are... but some aren't).

Also, there's the "gotcha" that the client needs to "know" what the class
is... so it needs to have a local reference to the server class. This defeats
the purpose of remoting because then you need a COPY of the server class on
the client even though it's actually executing somewhere else.... sooooo, the
easy solution is for YOURCLASS to imlement an Interface defined in a "shim"
dll that both client and server can share. The lightweight dll (containing
Interface definitions only) would then accomplish the same exact thing as a
Type Library (.tlb) in ol' COM or WSDL file in Web Services.

More info: check out:
http://msdn.microsoft.com/architectu...SecNetHT15.asp
"Ravi J" wrote:
Thanks Peter and CMM.
Peter, I thought about using a shared drive, but then I don'treally need
..NEt framework for this. I am wondering if some sort of queue can be
established between client and the server where in the server keeps writing
in and the clients keep reading.
CMM, Thx for the code snippet, but I am a little confused. How does the
client establish a connection to the file stream that the server (or windows
service) is writing to?

Back in the COM days, you could invoke a COM component running inside a
service and still be able to communicate as if it were a simple local
object. Can something like that be done using .NET? One possibility I see is
somehow add a reference inside the client for the service and use the class.
Would that be possible? And also, how to impliment it if both client and the
service are running in seperate user account?

Again, thanks for your replies (past/advance)
Ravi
"CMM" <CM*@discussions.microsoft.com> wrote in message
news:50**********************************@microsof t.com...
That's such an old school COBOL-esque way of doing things.

If you're transferring files between client/server via remothing you'd

just
convert the filestream to a bytearray (code below) and return the

contents.
If you're worried about first "loading the file into memory" or

whatever...
consider this: this is pretty much exactly what the operating system does
even if you go the "polling" route suggested by others.

Dim fs As New System.IO.FileStream(theFile, IO.FileMode.Open,
IO.FileAccess.Read)
Dim bytes(CInt(fs.Length) - 1) As Byte '.length property is Long so it

needs
to be cast
fs.Read(bytes, 0, CInt(fs.Length))
fs.Close()
Return bytes

then just reverse the process on the client side.

"Peter Rilling" wrote:
Do they have a common drive they can access? If so, you could just write the file to disk and then let the service pick it up at scheduled intervals.
"Ravi J" <Ra***@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
> What is the best way to transfer files between two .NET executables?
> I have a service, and a client program. Client asks service for data. The > service creates one, and passes it back to client. Both programs run in ..NET
> framework.
> Given this requirement, how best to approach the issue? Does .NET
framework
> provides any class that can help?
> Thanks in advance,


Jul 21 '05 #8

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

Similar topics

8
by: Mike Smith | last post by:
If I put an old exe file on a web site and create a link to it then IE will ask "open or save to disk?" when clicked. When I create an exe with VS.NET it does not ask anything, it just tries to...
5
by: Daniel Fudge | last post by:
I'm trying to call an executable and read an object from it. For sake of simplicity say it's just the double "x". In my Read_Object.exe code I can call the program with the following. i =...
2
by: Niyazi | last post by:
Hi, I have BIG question and I gues it is the BEST question. I have a problem that I am guessing the best solution is to create some sort ..NET Services. This Service(s) must check every...
2
by: Piotr Karwatka | last post by:
Hi! I have a little problem an qeustion. In .NET Windows Forms I can do something like that: - i have forms - Form1 Form2, on first form i have TextBox1 control on 2nd form I have Button1...
7
by: Ravi J | last post by:
What is the best way to transfer files between two .NET executables? I have a service, and a client program. Client asks service for data. The service creates one, and passes it back to client....
5
by: Pilence | last post by:
Hy!! Can someone tell me please how to do this type of work done by using C#......
2
by: mcdesigns | last post by:
Recently suffered a bad hard drive crash. Was able to recover most of my old source files, but most were corrupted. Does anyone know if Visual Studio does any caching of source files? Have tried...
0
nomad
by: nomad | last post by:
Hello Everyone: I need some help with transfering a db from my computer to the host. I'm not to sure how to do this so that the webpage know where the db is at. Here is what I have... I'm using...
3
by: Mohit | last post by:
Hi All, I have some batch files which needs to be executed when installer is running. How can I achieve this functionality using .Net MSI installers. I didn't found any option where I can include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.