title: System.ArgumentException: Illegal characters in path
body: <p>I am trying to decrypt an encrypted file, however I am getting the <code>System.ArgumentException: Illegal characters in path.</code> error in line 4 of the above method (StreamReader...). Can anyone tell me why this exact error is happening? I dont have any path being passed the method where error is occuring however the path from the previous method is an absolute path of the file to decrypt</p>
  
  <p>Method:</p>
  
  <pre><code>   public static string AsymmDecrypt(string input, string privatekeyfilename)
          {
              RSACryptoServiceProvider myAlg = new RSACryptoServiceProvider();
              StreamReader sr = new StreamReader(privatekeyfilename);
              myAlg.FromXmlString(sr.ReadLine());
              sr.Close();
  
              byte[] cipher = myAlg.Decrypt(Convert.FromBase64String(input), true);
              return UTF8Encoding.UTF8.GetString(cipher);
          }
  </code></pre>
  
  <p>Parameters being passed:</p>
  
  <pre><code>input = "����\0JFIF\0\0H\0H\0\0��\0C\0\b"
  
  privatekeyfilename = "&lt;RSAKeyValue&gt;&lt;Modulus&gt;2o6sUW4eEF43RK6SWyxuII0wfmhyiTXkBVX8l5J20Y5IvY10/7W3vT0RkwB/lcZUNUgOC2PG6ISJQ53PR76yybSodU9uNmYZye+eJnImP+a6SFZKMxeFESFkye5kroHc4qQ76Zyb37YcMulD214EWnyiu3gcBoA5yyOXyM8PojU=&lt;/Modulus&gt;&lt;Exponent&gt;AQAB&lt;/Exponent&gt;&lt;P&gt;7Ke13x362OFEr7VjYmpJOpC+...
  </code></pre>
  
  <p>Stack Trace:</p>
  
  <pre><code>    [ArgumentException: Illegal characters in path.]
     System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) +10631190
     System.IO.Path.GetFileName(String path) +21
     System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost) +82
     System.IO.StreamReader..ctor(String path) +32
     eLearningLTD.Securities.EncryptDecrypt.AsymmDecrypt(String input, String privatekeyfilename) in D:\Assignments\SSD\aAssignment\eLearningLTD\eLearningLTD\Securities\EncryptDecrypt.cs:211
     eLearningLTD.Securities.EncryptDecrypt.HybridDecryption(String filePath, String publicKey, String privateKey) in D:\Assignments\SSD\aAssignment\eLearningLTD\eLearningLTD\Securities\EncryptDecrypt.cs:178
     eLearningLTD.Controllers.ResourcesController.download(String id) in D:\Assignments\SSD\aAssignment\eLearningLTD\eLearningLTD\Controllers\ResourcesController.cs:213
     lambda_method(Closure , ControllerBase , Object[] ) +180
     System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
     System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
     System.Web.Mvc.&lt;&gt;c__DisplayClass15.&lt;InvokeActionMethodWithFilters&gt;b__12() +55
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
     System.Web.Mvc.&lt;&gt;c__DisplayClass17.&lt;InvokeActionMethodWithFilters&gt;b__14() +21
     System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
     System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
     System.Web.Mvc.Controller.ExecuteCore() +106
     System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
     System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
     System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +34
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +19
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +10
     System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
     System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +48
     System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7
     System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
     System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
     System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155
  </code></pre>