다음을 통해 공유


VSProject2.GetUniqueFilename 메서드 (Object, String, String)

이 메서드는 프로젝트 내에서 고유한 파일 이름을 생성합니다. 이 이름은 새 프로젝트 항목 이름을 지정하는 데 사용됩니다.

네임스페이스:  VSLangProj80
어셈블리:  VSLangProj80(VSLangProj80.dll)

구문

‘선언
Function GetUniqueFilename ( _
    pDispatch As Object, _
    bstrRoot As String, _
    bstrDesiredExt As String _
) As String
string GetUniqueFilename(
    Object pDispatch,
    string bstrRoot,
    string bstrDesiredExt
)
String^ GetUniqueFilename(
    [InAttribute] Object^ pDispatch, 
    [InAttribute] String^ bstrRoot, 
    [InAttribute] String^ bstrDesiredExt
)
abstract GetUniqueFilename : 
        pDispatch:Object * 
        bstrRoot:string * 
        bstrDesiredExt:string -> string 
function GetUniqueFilename(
    pDispatch : Object, 
    bstrRoot : String, 
    bstrDesiredExt : String
) : String

매개 변수

  • pDispatch
    형식: System.Object
    이 값은 생성될 이름의 확장명으로 사용됩니다.
  • bstrRoot
    형식: System.String
    Project 개체 또는 폴더 ProjectItem 개체입니다.생성되는 파일 이름은 이 컨텍스트 내에서 고유합니다.
  • bstrDesiredExt
    형식: System.String
    생성되는 이름은 이 문자열로 시작됩니다.

반환 값

형식: System.String
프로젝트 또는 프로젝트 폴더에서 고유한 파일 이름을 나타내는 문자열입니다.첫째 매개 변수가 Project 인스턴스인 경우 생성되는 이름은 루트 프로젝트 폴더에서 고유합니다.파일 이름 형식은 Root?.Extension이며 여기에서 ?는 하나 이상의 숫자(1, 2, 3 등)입니다.

구현

VSProject.GetUniqueFilename(Object, String, String)

설명

이 메서드는 주로 새 프로젝트 항목의 이름을 생성할 때 사용합니다.

KeyFile을 루트로 사용하고 snk를 확장명으로 사용하여 이 메서드를 호출할 경우, KeyFile.snk 파일이 없으면 KeyFile.snk 문자열이 반환되고 KeyFile.snk 파일이 이미 있으면 KeyFile1.snk가 반환됩니다. 이 메서드를 여러 번 호출하는 경우, 반환된 파일 이름을 사용하여 파일이 생성되지 않으면 모든 호출에서 같은 값이 반환됩니다. 이 경우 메서드를 호출할 때 존재하는 파일만 결과에 영향을 줍니다.

예제

이 예제에서는 프로젝트 폴더에서 고유한 파일 이름을 root?.ext 형식으로 표시합니다. 이 예제를 추가 기능으로 실행하려면 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오. 이 예제를 실행하기 전에 Visual Basic 또는 Visual C# 프로젝트를 엽니다.

[Visual Basic]

' 이 예제에서는 다음에 고유한 파일 이름을 표시합니다.

' project folder, in the form, root?.ext.
Public Sub OnConnection(ByVal application As Object,_
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    GetUniqueName(applicationObject)
End Sub
Sub GetUniqueName(ByVal dte As DTE2)
    Dim proj As Project
    proj = applicationObject.Solution.Projects.Item(1)
    Dim vsproj As VSLangProj80.VSProject2 = _
    CType(proj.Object, VSLangProj80.VSProject2)
    MsgBox(vsproj.GetUniqueFilename(proj, "Root", "ext"))
End Sub

[C#]

using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
// This example displays a file name that is unique in the 
// project folder, in the form, root?.ext.
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    GetUniqueName((DTE2)applicationObject);
}
public void GetUniqueName(DTE2 dte)
{
    Project proj = null;
    proj = applicationObject.Solution.Projects.Item(1);
    VSLangProj80.VSProject2 vsproj = 
((VSLangProj80.VSProject2)(proj.Object));
    MessageBox.Show(vsproj.GetUniqueFilename(proj, "Root", "ext"));
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

VSProject2 인터페이스

GetUniqueFilename 오버로드

VSLangProj80 네임스페이스