2011-06-21 75 views
0

wptf c#でレポートを作成するためにfile.rdlを書き込む必要がありますが、「c:\ Documentへのアクセスが拒否され、Setting \ SipusProv \一時\ reportTemp.rdl これは私のソースコードです:。パスへのアクセスが拒否されました。C:WPF C#

private void LaporanRdl(string rdl, DataSet data, string judul) 
    { 

     DataSet dt = data; 
     dt.DataSetName= "Data"; 
     Masaddy.Reprot report = new Masaddy.Reprot(); 
     try 
     { 

      //System.IO.StreamReader strReader = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\rdl\" + rdl + ".rdl"); 
      System.IO.StreamReader strReader = new System.IO.StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\rdl\" + rdl + ".rdl"); 
      string pathTemp = AppDomain.CurrentDomain.BaseDirectory + @"Temp\reportTemp.rdl"; 
      System.IO.StreamWriter strWriter = new System.IO.StreamWriter(pathTemp); 

     string strIsi = ""; 
     while (strIsi != "</Report>") 
     { 

      strIsi = strReader.ReadLine().Trim(); 
      if (strIsi == "<Value>txtDep</Value>") 
      { 
       strIsi = "  <Value>" + this.ddDeputi.SelectedItem.ToString() + "</Value>"; 

      } 
      if (strIsi == "<Value>txtDir</Value>") 
      { 
       strIsi = "  <Value>" + this.ddDir.SelectedItem.ToString() + "</Value>"; 

      } 
      if (strIsi == "<Value>txtSubDir</Value>") 
      { 
       strIsi = "  <Value>" + this.ddSubDir.SelectedItem.ToString() + "</Value>"; 

      } 
      if (strIsi == "<Value>txtTahun</Value>") 
      { 
       strIsi = "  <Value>" + this.txtTahun.Text.ToString() + "</Value>"; 

      } 
      strWriter.WriteLine(strIsi); 
     } 
     strWriter.Dispose(); 
     Masaddy.ReportForm r = new Masaddy.ReportForm(AppDomain.CurrentDomain.BaseDirectory + @"\\Temp\\reportTemp.rdl", "Data", dt.Tables[0]); 
     r.Text = judul; 
     r.Show(); 
     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message.ToString()); 
     } 

    } 
+0

使用しているウィンドウのバージョンは? –

+2

あなたはパーミッションをチェックしましたか?ファイルは別のプロセスで開いていますか?ファイルは読み取り専用ですか?これまでに何を確認しましたか? – Cameron

+2

また、あなたの質問とはまったく無関係ですが、すばらしい 'System.Path'クラス(特に[' Combine() '](http://msdn.microsoft.com/en-us/library/ fyy7a5kt.aspx)メソッド)。 – Cameron

答えて

0

私はuが のWindows Vista/7でプログラムを実行すると思うアプリケーションマニフェストファイルを使用しようと

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> 
<security> 
    <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> 
    <!-- UAC Manifest Options 
     If you want to change the Windows User Account Control level replace the 
     requestedExecutionLevel node with one of the following. 

    <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 
    <requestedExecutionLevel level="highestAvailable" uiAccess="false" /> 

     Specifying requestedExecutionLevel node will disable file and registry virtualization. 
     If you want to utilize File and Registry Virtualization for backward 
     compatibility then delete the requestedExecutionLevel node. 
    --> 
    <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 
    </requestedPrivileges> 
</security> 

1

「アクセスが拒否されました。実際の質問は

  • あなたのコードはどのようなユーザとして実行されていますか?
  • 失敗した操作の影響を受けるリソースはどれですか?
  • これらのリソースには、通常どのような権限がありますか?
  • UACはプレイ中ですか?

他の国にあなたの特定のシステム上でのアクセス許可の理由を尋ねるのは良いことではありません。あなただけがそれを調査する立場にいます。

この「質問」は、「plz send me teh configz」と言い切ってしまう恐れがあります。

関連する問題