使用 Visual Studio Extension 创建一个文本文件,并填入内容。

需要引用 EnvDTE

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\EnvDTE.dll

代码如下:

using System;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop; using EnvDTE; namespace CreateTextView
{
public static class CreateNew
{
public static void TextFile(string title, string fileContents)
{
DTE dte = (DTE)Package.GetGlobalService(typeof(DTE));
Window win = dte.ItemOperations.NewFile("General\\Text File", title, EnvDTE.Constants.vsViewKindTextView); TextSelection txtSel = (TextSelection)dte.ActiveDocument.Selection;
TextDocument txtDoc = (TextDocument)dte.ActiveDocument.Object(""); txtSel.SelectAll();
txtSel.Delete();
txtSel.Insert(fileContents);
txtSel.GotoLine();
}
}
}

在做Visual Studio 的插件时,使用自带的文本显示大文件快而且稳定。

使用RichTextBox显示大文件容易卡死。

VS Extension: Create a txt file and set the content的更多相关文章

  1. 解决: org.iq80.leveldb.DBException: IO error: C:\data\trie\000945.sst: Could not create random access file.

    以太坊MPT树的持久化层是采用了leveldb数据库,然而在抽取MPT树代码运行过程中,进行get和write操作时却发生了错误: Caused by: org.fusesource.leveldbj ...

  2. sqlplus链接数据库报ORA-09925: Unable to create audit trail file

    [localhost.localdomain]:[/oracle11/app/oracle11/product/11.2.0/dbhome_1/dbs]$ sqlplus / as sysdba SQ ...

  3. Can't create/write to file '/tmp/#sql_887d_0.MYD' (Errcode: 17)

    lsof |grep "#sql_887d_0.MYD" 如果没有被占用就可以删掉 . https://wordpress.org/support/topic/cant-creat ...

  4. ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI' (Errcode: 13)

    mysql> desc tablename; ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI' (Errcode ...

  5. Can't create/write to file '/tmp/#sql_3105_0.MYI' (Errcode: 13)

    最近的项目中由于临时存储空间太大了.索性把tmp目录删除了.结果访问出现 Can't create/write to file '/tmp/#sql_3105_0.MYI' (Errcode: 13) ...

  6. [问题解决] initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock

    错误: 在linux下开启mongoDB的 $ >bin: ./mongod 时报错:initAndListen: 10309 Unable to create/open lock file: ...

  7. How do I create a zip file?(转)

    Creating a zip file is a task that can easily be accomplished by using the classes ZipOutputStream a ...

  8. OUI-67076 : OracleHomeInventory was not able to create a lock file" in Unix

    Symptoms The command "opatch lsinventory" reports the error: OUI-67076:OracleHomeInventory ...

  9. How to create a zip file in NetSuite SuiteScript 2.0 如何在现有SuiteScript中创建和下载ZIP压缩文档

    Background We all knows that: NetSuite filecabinet provided a feature to download a folder to a zip ...

随机推荐

  1. Android 自学之基本界面组件(上)

    文本款(TextView)和编辑框(EditText)的功能和用法 TextView直接继承了View,他还是EditText.Button两个UI组件的父类,TextView的作用就是在界面上显示文 ...

  2. $GLOBALS['HTTP_RAW_POST_DATA']、$_POST和php://input深入探究三者的区别

    $_POST:通过 HTTP POST 方法传递的变量组成的数组.是自动全局变量. $GLOBALS['HTTP_RAW_POST_DATA'] :总是产生 $HTTP_RAW_POST_DATA 变 ...

  3. scala学习笔记:变量声明中的模式

    先看个正常的写法: scala> val x = 1 x: Int = 1 体会一下元组的写法: scala> val (x,y,z)=(1,2,3) x: Int = 1 y: Int ...

  4. 2 WPF之XMAL----XMAL概览

    转载:http://blog.csdn.net/fwj380891124/article/details/8085458 微软为了把开发模式从网络开发移植到桌面开发和富媒体网络程序的开发上,微软创造了 ...

  5. Android Activity常用生命周期函数

    在Activity中主要有7个常用的周期函数,他们分别是: (一)onCreate 在Activity对象被第一次创建时调用 注: 从另一个Activity返回到前一个Activity时,不会调用该函 ...

  6. 再探Linux动态链接 -- 关于动态库的基础知识

      在近一段时间里,由于多次参与相关专业软件Linux运行环境建设,深感有必要将这些知识理一理,供往后参考. 编译时和运行时 纵观程序编译整个过程,细分可分为编译(Compiling,指的是语言到平台 ...

  7. and or判别

    and 和 or涉及到短路运算,python把0,'',none看做false,其余是true, 对于a and b,若a是true则,返回b,若a是false则返回a(因为a是true还需要判断b, ...

  8. ### MATLAB - CUDA

    MATLAB下使用CUDA. #@author: gr #@date: 2014-04-08 #@email: forgerui@gmail.com 一. Matlab & C 1. 概念 M ...

  9. ###学习《C++ Primer》- 5

    点击查看Evernote原文. // @author: gr // @date: 2014-10-20 // @email: forgerui@gmail.com Part 5: 动态内存(第12章) ...

  10. asp.net 邮件发送类

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...