Solved

c#, VS2012 -- use code to move a file on Windows machine to AS400

Posted on 2013-12-20
1
371 Views
Last Modified: 2014-01-03
I have an executable that is being scheduled to run via Windows Task Manager and must write a flat file from a Windows machine to an AS400 programatically.  The AS400 needs log in information.

So, in other words, when I do something like:

                    sw = new StreamWriter(this._APDeliveryPath + "APDIST" + sDate + ".txt");

this._APDeliveryPath is expressed something like \\as400server\folde\folder\folder ...

I don't have access to the AS400 without logging into it.

Can this be done programatically?
0
Comment
Question by:g_johnson
1 Comment
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 500 total points
ID: 39754757
Yes it can be done programmatically. What you will need to do is impersonate a different user while executing the code that does the copy. You can find examples and sample code at the following links.

http://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User

http://www.codeproject.com/Articles/4051/Windows-Impersonation-using-C

http://stackoverflow.com/questions/1168571/run-code-as-a-different-user-c
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question