الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ما المشكلة في كود عرض محتوى فايل

بدأه easy_3a3 في 8 سبتمبر 2010 · 2 رد · 389 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

GetMyFile()

End Sub

Function GetMyFile()

Dim d As String = "Word.doc"

'Return Request.PhysicalApplicationPath & "/ff/" & ss

Dim sss As New StreamReader(Request.PhysicalApplicationPath & "/ff/" & d)

Dim dds As String = sss.ReadToEnd

Return dds

<iframe id="file" src='<%# GetMyFile() %>' style="width: 100%; height: 257px" frameborder="0"></iframe>

#2

جرب هذا الكود

ٌُReading word File

أو جرب هذا الكود ..

<%@ Import Namespace="System.IO" %>
<script language="vb" runat="server">
  sub Page_Load(sender as Object, e as EventArgs)
    'Open a file for reading
    Dim FILENAME as String = Server.MapPath("Rand.txt")

    'Get a StreamReader class that can be used to read the file
    Dim objStreamReader as StreamReader
    objStreamReader = File.OpenText(FILENAME)

    'Now, read the entire file into a string
    Dim contents as String = objStreamReader.ReadToEnd()

    'Set the text of the file to a Web control
    lblRawOutput.Text = contents

    'We may wish to replace carriage returns with <br>s
    lblNicerOutput.Text = contents.Replace(vbCrLf, "<br>")

    objStreamReader.Close()
  end sub
</script>

    <b>Raw File Output</b><br />
    <asp:label runat="server" id="lblRawOutput" />
    <p>
    <b>Nicer Output</b><br />
    <asp:label runat="server" id="lblNicerOutput" Font-Name="Verdana" />

ٌReading Text File

تم تعديل هذه المشاركة بواسطة مبرمج القاعده في 12 سبتمبر 2010 في 14:22

اللهم أطل عمري وأحسن عملي واختم بالشهادة أجلي

#3
easy_3a3 كتب:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

GetMyFile()

End Sub

Function GetMyFile()

Dim d As String = "Word.doc"

'Return Request.PhysicalApplicationPath & "/ff/" & ss

Dim sss As New StreamReader(Request.PhysicalApplicationPath & "/ff/" & d)

Dim dds As String = sss.ReadToEnd

Return dds

<iframe id="file" src='<%# GetMyFile() %>' style="width: 100%; height: 257px" frameborder="0"></iframe>

يمكنك وضع كود الدالة فى httpHandler وهى ستقوم بدور مسار الملف هكذا :

<iframe runat="server" id="myframe" src="Handler.ashx"  >
    </iframe>

للعلم : تمت التجربة واثبتت نجاح مع ملف Word . فى أمان الله .

Ahmed Moosa

Microsoft Community Contributor | MCC

Microsoft Certified Professional Developer | MCPD

Microsoft Certified Technology Specialist | MCTS

Senior .NET Developer

.Net Trainer

English blog : http://weblogs.asp.net/ahmedmoosa/

مدونة عربى : http://ahmedmoosa.wordpress.com/

مواضيع مشابهة