---
title: "VB.Net获取程序所在的工作目录"
author: "kiki1120"
date: "2012-08-23T16:34:09Z"
tags: []
categories: ["编程语言"]
slug: "vb-net"
draft: false
lastmod: "2013-03-12T21:55:05Z"
id: 1660001
url: "https://mimmy.iteye.com/blog/1660001"
---

'读取程序所在工作目录下debug.txt文件内容，设置DEBUG标志

Dim debug = False

Dim debugFile As String

debugFile = Application.StartupPath & "\\debug.txt"

'检查文件是否存在

If My.Computer.FileSystem.FileExist(debugFile) Then

    '读取文件全部内容

    If My.Computer.FileSystem.ReadAllText(debugFile).StartsWith("1") Then

        DEBUG = True

    End If

End If