Solution4.SaveAs(String) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
保存解决方案。
public:
void SaveAs(System::String ^ FileName);
public:
void SaveAs(Platform::String ^ FileName);
void SaveAs(std::wstring const & FileName);
[System.Runtime.InteropServices.DispId(14)]
public void SaveAs (string FileName);
[<System.Runtime.InteropServices.DispId(14)>]
abstract member SaveAs : string -> unit
Public Sub SaveAs (FileName As String)
参数
- FileName
- String
必需。 用于保存解决方案的文件名。 如果该文件存在,它会被覆盖。
实现
- 属性
示例
Sub SaveAsExample(ByVal dte As DTE2)
' Create a solution and then saves it.
' Create the full path to NewSolution.sln.
Dim tempPath As String = System.IO.Path.GetTempPath()
Dim solnName As String = "NewSolution"
Dim solnPath As String = tempPath & solnName & ".sln"
Dim soln As Solution2 = _
CType(_applicationObject.Solution, Solution2)
Try
If MsgBox("Solution " & solnPath & " doesn't exist. " & _
"Create it?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
' Create and save NewSolution.sln.
dte.Solution.Create(tempPath, solnName)
dte.Solution.SaveAs(solnPath)
End If
Catch ex As SystemException
MsgBox("ERROR: " & ex.ToString())
End Try
End Sub
using System.Windows.Forms;
public void SolnSaveAsExample(DTE2 dte)
{
// Create a solution and save it.
string tempPath = System.IO.Path.GetTempPath();
string solnName = "NewSolution";
string solnPath = tempPath + solnName + ".sln";
Solution2 soln = (Solution2)_applicationObject.Solution;
try
{
if (MessageBox.Show("Solution " + solnPath +
" doesn't exist. " + "Create it?", "",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// Create and save NewSolution.sln.
dte.Solution.Create(tempPath, solnName);
dte.Solution.SaveAs(solnPath);
}
}
catch (SystemException ex)
{
MessageBox.Show("ERROR: " + ex);
}
}
注解
SaveAs 用指定的文件名保存解决方案。