Click here to Skip to main content
15,915,975 members
Home / Discussions / C#
   

C#

 
AnswerRe: Editing a string Pin
Dustin Metzgar17-Aug-06 5:31
Dustin Metzgar17-Aug-06 5:31 
QuestionMacro to refresh solution explorer's folder Pin
Marco225017-Aug-06 3:34
Marco225017-Aug-06 3:34 
Hi all.

Does anyone know how I can refresh a folder (like App_References) in solution explorer using a macro?

This because I'd wrote a macro that refresh automatically all web references. But after this, the solution explorer don't show web service related files (.dico, .discomap, etc).

The macro:
[code]
Option Explicit On

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports System.IO
Imports VSLangProj
Imports System.net

Public Module Macros
Sub UpdateWebReferences()
Dim vswebsite As VsWebSite.VSWebSite
Dim vswebsiteRefs As New System.Collections.ArrayList

For i As Integer = 1 To DTE.Solution.Projects.Count
'MsgBox(Microsoft.VisualBasic.Information.TypeName(DTE.Solution.Projects.Item(i).Object))

'Change this with full web project path
If "C:\Projetos\Internos\SmartSeguro\Code\Seguro.Web\" = DTE.Solution.Projects.Item(i).Name Then
vswebsite = CType(DTE.Solution.Projects.Item(i).Object, VsWebSite.VSWebSite)
'vswebsite.p()

For j As Integer = 1 To vswebsite.WebReferences.Count
Dim webRef As VsWebSite.WebReference = vswebsite.WebReferences.Item(j)
Dim wsPath As String = Path.GetDirectoryName(webRef.ProjectItem.FileNames(0))

Dim item As New WebServiceItem
item.url = webRef.ServiceLocationUrl
item.nNameSpace = webRef.Namespace
item.dirPath = wsPath
item.serviceName = webRef.ServiceName
item.ReadWsdl()

Dim fs As New FileStream(wsPath + "\" & webRef.ServiceName & ".disco", FileMode.Open)
Dim teste() As Byte
ReDim teste(fs.Length - 1)
fs.Read(teste, 0, fs.Length)
fs.Close()
item.disco = New MemoryStream(teste)

fs = New FileStream(wsPath + "\" & webRef.ServiceName & ".discomap", FileMode.Open)
Dim teste2() As Byte
ReDim teste2(fs.Length - 1)
fs.Read(teste2, 0, fs.Length)
fs.Close()
item.discoMap = New MemoryStream(teste2)

vswebsiteRefs.Add(item)
webRef.Remove()
Directory.Delete(wsPath)

If vswebsite.WebReferences.Count = 0 Then
Exit For
End If

j = 0
Next

For j As Integer = 0 To vswebsiteRefs.Count - 1
Dim webRef As WebServiceItem = vswebsiteRefs(j)

Directory.CreateDirectory(webRef.dirPath)

Dim fs As New FileStream(webRef.dirPath + "\" + webRef.serviceName + ".disco", FileMode.Create)
fs.Write(webRef.disco.ToArray(), 0, webRef.disco.Length)
fs.Close()

fs = New FileStream(webRef.dirPath + "\" + webRef.serviceName + ".discomap", FileMode.Create)
fs.Write(webRef.discoMap.ToArray(), 0, webRef.discoMap.Length)
fs.Close()

fs = New FileStream(webRef.dirPath + "\" + webRef.serviceName + ".wsdl", FileMode.Create)
fs.Write(webRef.wsdl.ToArray(), 0, webRef.wsdl.Length)
fs.Close()

vswebsite.WebReferences.Add(webRef.url, webRef.nNameSpace)
Next

'Implementar: Refresh na pasta.
For j As Integer = 1 To vswebsite.Project.ProjectItems.Count
If vswebsite.Project.ProjectItems.Item(3).Name = "App_WebReferences" Then
End If
Next

Exit For
End If
Next
End Sub
End Module

Class WebServiceItem
Public url As String
Public nNameSpace As String
Public dirPath As String
Public serviceName As String

Public disco As New MemoryStream
Public discoMap As New MemoryStream
Public wsdl As New MemoryStream

Public Sub ReadWsdl()
Dim wr As HttpWebRequest = WebRequest.Create(url & "?WSDL")
Dim sr As New StreamReader(wr.GetResponse().GetResponseStream(), System.Text.Encoding.GetEncoding(1252))

Dim teste2 As String = sr.ReadToEnd()
sr.Close()
Dim teste() As Byte = System.Text.Encoding.ASCII.GetBytes(teste2)

wsdl.Write(teste, 0, teste.Length)
End Sub
End Class

[/code]

QuestionFirst cold startup time Pin
Super Lloyd17-Aug-06 2:45
Super Lloyd17-Aug-06 2:45 
AnswerRe: First cold startup time Pin
V.17-Aug-06 4:50
professionalV.17-Aug-06 4:50 
GeneralRe: First cold startup time Pin
Super Lloyd17-Aug-06 4:54
Super Lloyd17-Aug-06 4:54 
GeneralRe: First cold startup time Pin
Dan Neely17-Aug-06 5:54
Dan Neely17-Aug-06 5:54 
GeneralRe: First cold startup time Pin
Super Lloyd17-Aug-06 6:07
Super Lloyd17-Aug-06 6:07 
QuestionCOM interop to communicate with Word Pin
TAREQ F ABUZUHRI17-Aug-06 2:42
TAREQ F ABUZUHRI17-Aug-06 2:42 
AnswerRe: COM interop to communicate with Word Pin
Michael P Butler17-Aug-06 3:16
Michael P Butler17-Aug-06 3:16 
QuestionEigen vector Pin
vickyProgrammer17-Aug-06 2:21
vickyProgrammer17-Aug-06 2:21 
AnswerRe: Eigen vector Pin
Super Lloyd17-Aug-06 2:40
Super Lloyd17-Aug-06 2:40 
QuestionIs there any way ... Pin
mostafa_h17-Aug-06 1:57
mostafa_h17-Aug-06 1:57 
AnswerRe: Is there any way ... Pin
lmoelleb17-Aug-06 2:13
lmoelleb17-Aug-06 2:13 
GeneralRe: Is there any way ... [modified] Pin
mostafa_h17-Aug-06 2:21
mostafa_h17-Aug-06 2:21 
GeneralRe: Is there any way ... Pin
lmoelleb17-Aug-06 3:23
lmoelleb17-Aug-06 3:23 
GeneralRe: Is there any way ... Pin
mostafa_h17-Aug-06 3:35
mostafa_h17-Aug-06 3:35 
GeneralRe: Is there any way ... Pin
lmoelleb17-Aug-06 7:05
lmoelleb17-Aug-06 7:05 
GeneralRe: Is there any way ... Pin
mostafa_h17-Aug-06 7:42
mostafa_h17-Aug-06 7:42 
QuestionAccessing Visual Source Safe or VSS using C# Pin
Sriramv8217-Aug-06 1:53
Sriramv8217-Aug-06 1:53 
AnswerRe: Accessing Visual Source Safe or VSS using C# Pin
lmoelleb17-Aug-06 2:14
lmoelleb17-Aug-06 2:14 
AnswerRe: Accessing Visual Source Safe or VSS using C# Pin
Kevin McFarlane17-Aug-06 4:55
Kevin McFarlane17-Aug-06 4:55 
GeneralRe: Accessing Visual Source Safe or VSS using C# Pin
Sriramv8217-Aug-06 20:19
Sriramv8217-Aug-06 20:19 
GeneralRe: Accessing Visual Source Safe or VSS using C# Pin
Kevin McFarlane18-Aug-06 0:10
Kevin McFarlane18-Aug-06 0:10 
GeneralRe: Accessing Visual Source Safe or VSS using C# Pin
Sriramv8218-Aug-06 1:08
Sriramv8218-Aug-06 1:08 
GeneralRe: Accessing Visual Source Safe or VSS using C# Pin
KPmylsamy20-Jan-09 20:12
KPmylsamy20-Jan-09 20:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.