如何在VB.net中添加时间戳文件名的扩展名 [英] How to add an extension to a Timestamp file name in VB.net

查看:180
本文介绍了如何在VB.net中添加时间戳文件名的扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#我想将 .hl7 扩展名添加到文件名中,并使用时间戳作为文件名,我不知道如何继续



# I want to add .hl7 extension to the file name and am using timestamp for file name, I have no idea how to proceed

Private Sub HL_Click(sender As Object, e As EventArgs) Handles HL.Click

        Dim file As System.IO.StreamWriter
        Dim fileDateTime As String = DateTime.Now.ToString("yyyyMMdd") & "" & DateTime.Now.ToString("HHmmss")
        file = My.Computer.FileSystem.OpenTextFileWriter(fileDateTime, True)

            file.WriteLine("MSH|^~\&|||||" & TxtExamtime.Text & "||ORM^O01||P|2.3.1")
            file.WriteLine("PID|||" & TxtId.Text & "||" & TxtFamilyname.Text & "^" & TxtGivenname.Text & "||" & TxtDob.Text & "||" & TxtGender.Text & "|||" & TxtStreet.Text & " " & TxtHouse.Text & "^^" & TxtCity.Text & "^^" & TxtPostcode.Text)
            file.WriteLine("PV1||O|||||||||||||||||" & TxtId.Text & "|||||||||||||||||||||||||" & TxtExamdate.Text)
            file.WriteLine("ORC|NW|" & TxtId.Text & "|||||^^^" & TxtExamdate.Text & "||" & TxtExamdate.Text)
            file.WriteLine("OBR||" & TxtExamdate.Text & TxtExamdate.Text & "||CT|||" & TxtExamtime.Text & "|" & TxtExamtime.Text)
            file.WriteLine()

        file.Close()
        MessageBox.Show("Textsaved to " & fileDateTime)
    End Sub

推荐答案

试试这个:



Try this:

' ...
Dim fileDateTime As String = DateTime.Now.ToString("yyyyMMdd") & DateTime.Now.ToString("HHmmss") & ".hl7"
' ...


这篇关于如何在VB.net中添加时间戳文件名的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆