vb點(diǎn)虐 打開文件類 vbnet打開文件路徑

vb點(diǎn)虐 打開文件夾

System.Windows.Forms.OpenFileDialog

我們提供的服務(wù)有:成都做網(wǎng)站、成都網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、永嘉ssl等。為上千余家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的永嘉網(wǎng)站制作公司

System.Windows.Forms.SaveFileDialog

System.Windows.Forms.FolderBrowserDialog

以上三個(gè)類均能夠很好的解決樓主的需求。

具體的請(qǐng)lz自己查msdn

vb點(diǎn)虐 如何打開txt文件?

說明:以下代碼在Microsoft Visual Basic 2005 (簡(jiǎn)體中文版)中通過。

創(chuàng)建新項(xiàng)目:

在窗體上添加文本框2個(gè):TextBox1,TextBox2

TextBox1 -- 用來編輯要寫入的文本文件的內(nèi)容,或顯示打開的文本文件的內(nèi)容

TextBox2 -- 用來輸入要打開或要寫入的文件名(包括盤符,路徑)(例如:c:\123.txt)

在窗體上添加2個(gè)按鈕:Button1,Button2

Button1 -- 寫入文件

Button2 -- 打開文件

代碼如下:

Imports System.IO

Public Class Form1

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

Dim w As New StreamWriter(TextBox2.Text)

w.Write(TextBox1.Text)

w.Close()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim r As New StreamReader(TextBox2.Text)

Dim s As String

TextBox1.Text = ""

Do While r.Peek -1 '是否到文件尾

s = r.ReadLine

' MessageBox.Show(r.Peek)

TextBox1.Text = TextBox1.Text s vbCrLf

Loop

r.Close()

End Sub

End Class

補(bǔ)充:你要把讀出的數(shù)據(jù)賦值給一個(gè)變量,只要:聲明一個(gè)變量為數(shù)值類型,然后只要讀取一行就可以了,把這行數(shù)據(jù)經(jīng)過轉(zhuǎn)換成數(shù)值后賦給這個(gè)變量.

vbnet打開文件夾下打開jpg和png

XPS文件格式經(jīng)常在文件處理應(yīng)用程序中使用。您可以在基于.NET Framework的應(yīng)用程序中使用C#或VB.NET以編程方式將XPS或OXPS轉(zhuǎn)換為JPG或PNG圖像。

讓我們逐步介紹以下方案,以了解有關(guān)XPS轉(zhuǎn)換的更多信息:

使用C?;騐B.NET將XPS,OXPS轉(zhuǎn)換為JPG圖像

使用C?;騐B.NET將XPS,OXPS轉(zhuǎn)換為PNG圖像

目前,.NET版Aspose.page升級(jí)到v20.10版,感興趣的朋友可點(diǎn)擊下載

使用C?;騐B.NET將XPS,OXPS轉(zhuǎn)換為JPG圖像

JPG文件之所以出名是因?yàn)樗鼈冊(cè)谒邢到y(tǒng)環(huán)境中均受支持。您可以使用C#或VB.NET以編程方式將XPS或OXPS文件轉(zhuǎn)換為JPG圖像。對(duì)于XPS或OXPS到JPG圖像的轉(zhuǎn)換,應(yīng)遵循以下步驟:

加載輸入XPS或OXPS文件

初始化JpegSaveOptions對(duì)象

指定要渲染的SmoothingMode,Resolution和PageNumbers

保存輸出的JPG圖像

以下代碼顯示了如何使用C#語言將XPS或OXPS轉(zhuǎn)換為JPG圖像:

// Input file

string inputFileName = dataDir + "input.xps";

//Output file

string outputFileName = dataDir + "XPStoImage_out.jpeg";

// Initialize XPS input stream

using (Stream xpsStream = File.Open(inputFileName, FileMode.Open, FileAccess.Read))

{

// Load XPS document form the stream

XpsDocument document = new XpsDocument(xpsStream, new XpsLoadOptions());

// or load XPS document directly from file. No xpsStream is needed then.

// XpsDocument document = new XpsDocument(inputFileName, new XpsLoadOptions());

// Initialize options object with necessary parameters.

JpegSaveOptions options = new JpegSaveOptions()

{

SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality,

Resolution = 300

};

// Create rendering device for JPG format

ImageDevice device = new ImageDevice();

document.Save(device, options);

// Iterate through document partitions (fixed documents, in XPS terms)

for (int i = 0; i device.Result.Length; i++) // Iterate through partition pages for (int j = 0; j device.Result[i].Length; j++) { // Initialize image output stream using (Stream imageStream = System.IO.File.Open(Path.GetDirectoryName(outputFileName) + Path.GetFileNameWithoutExtension(outputFileName) + "_" + (i + 1) + "_" + (j + 1) + Path.GetExtension(outputFileName), System.IO.FileMode.Create, System.IO.FileAccess.Write)) // Write image imageStream.Write(device.Result[i][j], 0, device.Result[i][j].Length); } }

使用C#或VB.NET將XPS,OXPS轉(zhuǎn)換為PNG圖像

可能需要使用C#或VB.NET和Aspose.Page for .NET API將XPS或OXPS文件轉(zhuǎn)換為PNG。您需要按照以下步驟將XPS轉(zhuǎn)換為PNG:

加載輸入XPS或OXPS文件

初始化PngSaveOptions對(duì)象

設(shè)置圖像分辨率或頁面編號(hào)為渲染

保存輸出的PNG圖像

當(dāng)前標(biāo)題:vb點(diǎn)虐 打開文件類 vbnet打開文件路徑
路徑分享:http://muchs.cn/article38/ddcjspp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、電子商務(wù)、外貿(mào)建站定制網(wǎng)站、域名注冊(cè)面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司