Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2007, 12:45 PM
Authorized User
 
Join Date: Jul 2006
Posts: 22
Thanks: 1
Thanked 0 Times in 0 Posts
Default Callling cmd from ASP.NET web service

I have a file being retrieved from an FTP server (that part works) that needs to be encrypted. The below is the code I have which doesn't seem to be working. "FileEncrypter" is a command line executable that takes "File1.dd", encrypts it, and names the encrypted file "File1.edd". The only problem is, it doesn't seem to encrypt when this code is executed, but it does when I type it into a command prompt.

private void Encrypt()
{
    string path = System.Web.HttpContext.Current.Server.MapPath("/wsCN/data");
        string command = @"cd " + path + " & FileEncrypter -iFile1.dd -oFile1.edd";
    System.Diagnostics.Process.Start("cmd", command);
}


 
Old December 5th, 2007, 01:52 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

My first guess is that the web application lacks the correct permissions to write files. When you run it manually, you are doing so under your user account that has far more rights on your system.

Search for procedures for setting write permissions for ASP.NET web apps and see if that fixes the problem.

-Peter
 
Old December 5th, 2007, 04:46 PM
Authorized User
 
Join Date: Jul 2006
Posts: 22
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Permissions don't appear to be the issue here. Since I posted the original message, I noticed something quite important to the potential solution. When that method is executed by itself, the encryption process works as designed. When the previous method is executed, that's when the encryption does not happen. This method works because the datestamp on the file changes when it's called.

private void DownloadFile()
{
    string sSaveAddress = System.Web.HttpContext.Current.Server.MapPath("/wsCN") + "/data/File1.ee";
    System.Net.WebClient client = new System.Net.WebClient();
    client.Credentials = new System.Net.NetworkCredential(sUserId, sPwd);
    System.IO.Stream MyStream = client.OpenRead(sFolder);
    System.IO.BinaryReader MyStreamReader = new System.IO.BinaryReader(MyStream);
    System.Net.WebClient ftpClient = new System.Net.WebClient();
    System.IO.Stream MyWriteStream = ftpClient.OpenWrite(sSaveAddress, "PUT");
    System.IO.BinaryWriter MyStreamWriter = new System.IO.BinaryWriter(MyWriteStream);
    int rd = 0;
    long total = 0;
    int bufSize = 1024;
    byte[] buf = new byte[bufSize];
    while ((rd = MyStreamReader.Read(buf, 0, bufSize)) != 0)
    {
        total += rd;
        MyStreamWriter.Write(buf, 0, rd);
    }
    MyStream.Close();
    Encrypt();
}







Similar Threads
Thread Thread Starter Forum Replies Last Post
Publish ASP.Net Code with cmd Line using Process rhd110 General .NET 0 February 2nd, 2008 03:26 PM
publish asp.net site functionality as web service amzar .NET Web Services 2 August 14th, 2007 11:26 PM
Problem with creating ASP .NET web app/service reye VS.NET 2002/2003 1 December 28th, 2006 06:10 AM
Creating a web service in ASP.NET sanjeet General .NET 1 September 14th, 2005 02:46 PM
ASP.NET COM Wrapper for Web Service ashettleroe Classic ASP Professional 0 August 12th, 2005 05:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.