HtmlInputFile.Value プロパティ
アセンブリ: System.Web (system.web.dll 内)

public: virtual property String^ Value { String^ get () override; void set (String^ value) override; }
クライアントのファイルの完全パス。


Value プロパティは、クライアントのコンピュータ上のファイルの完全パス ("C:\MyFiles\Test.txt" など) を取得します。このプロパティは、ファイルを送信しているコンピュータに格納されているファイルの場所を調べる必要がある場合に役立ちます。また、元のファイルの名前を確認するときにも通常使用します。元のファイルの名前を取得するには、このプロパティの値を解析します。
![]() |
---|
Value プロパティは読み取り専用です。このプロパティに値を割り当てようとすると、System.NotSupportedException がスローされます。 |

Value プロパティを使用して、クライアントのコンピュータ上のファイルの完全パスを表示する方法を次のコード例に示します。この例を正常に動作させるには、コンピュータの C: ドライブに Temp というディレクトリを作成する必要があります。
<%@ Page Language="VB" AutoEventWireup="True" %> <script runat="server"> Public Sub Button1_Click(ByVal Source As Object, ByVal e As EventArgs) ' Make sure a file was submitted. If Text1.Value = "" Then Span1.InnerHtml = "Error: You must enter a file name." Return End If ' Save the file. If File1.PostedFile.ContentLength > 0 Then Try File1.PostedFile.SaveAs("c:\temp\" & Text1.Value) Span1.InnerHtml = "<b>" & File1.Value & "</b>" & _ " uploaded successfully to <b>c:\temp\" & _ Text1.Value & "</b> on the Web server." Catch exc As Exception Span1.InnerHtml = "Error saving file <b>c:\temp\" & _ Text1.Value & "</b><br>" & exc.ToString() & "." End Try End If End Sub </script> <html> <head> <title>HtmlInputFile Example</title> </head> <body> <h3>HtmlInputFile Example</h3> <form enctype="multipart/form-data" runat="server"> Select File to Upload: <input id="File1" type="file" runat="server"> <p> Save as file name (no path): <input id="Text1" type="text" runat="server"> </p> <p> <span id=Span1 style="font: 8pt verdana;" runat="server" /> </p> <p> <input type=button id="Button1" value="Upload" onserverclick="Button1_Click" runat="server"> </p> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="True" %> <script runat="server"> void Button1_Click(object Source, EventArgs e) { // Make sure a file was submitted. if (Text1.Value == "") { Span1.InnerHtml = "Error: You must enter a file name."; return; } // Save the file. if (File1.PostedFile.ContentLength > 0) { try { File1.PostedFile.SaveAs("c:\\temp\\" + Text1.Value); Span1.InnerHtml = "<b>" + File1.Value + "</b>" + " uploaded successfully to <b>c:\\temp\\" + Text1.Value + "</b> on the Web server."; } catch (Exception exc) { Span1.InnerHtml = "Error saving file <b>c:\\temp\\" + Text1.Value + "</b><br>" + exc.ToString() + "."; } } } </script> <html> <head> <title>HtmlInputFile Example</title> </head> <body> <h3>HtmlInputFile Example</h3> <form enctype="multipart/form-data" runat="server"> Select File to Upload: <input id="File1" type="file" runat="server"> <p> Save as file name (no path): <input id="Text1" type="text" runat="server"> </p> <p> <span id=Span1 style="font: 8pt verdana;" runat="server" /> </p> <p> <input type=button id="Button1" value="Upload" onserverclick="Button1_Click" runat="server"> </p> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlInputFile.Value プロパティを検索する場合は、下記のリンクをクリックしてください。

- HtmlInputFile.Value プロパティのページへのリンク