|
If i have a string
[name]MyName[/name]
How do i extract just the MyName part?
|
|
|
|
|
You could transform the string by doing a Replace('[', '<') and Replace(']', '>') and use XML.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
string theString = "[name]MyName[/name]";
int indexOfStart = theString.IndexOf(']');
int indexOfEnding = theString.LastIndexOf('[');
string name = theString.SubString(indexOfStart, indexOfEnding-indexOfStart);
|
|
|
|
|
string s = "[name]MyName[/name]";
Regex re = new Regex(@"\[\w+\](\w+)\[\/\w+\]");
Match m = re.Match(s);
Console.WriteLine(m.Groups[1]);
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
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]
|
|
|
|
|
A cold start of my application takes about 15 seconds. Further startup takes only 1 seconds.
After a reboot other cold start takes less than 15 seconds, perhaps 3~4s.
I tried to improve cold start by NGEN everything in the installer.
Now I don't know if I make an error or something in the installer but my cold first start time didn't imporve (after I tested it).
Any ideas on what I could do to improve my 1st cold start?
|
|
|
|
|
If there are a lot of things loading in the constructor, you could try to postpone those to when the user actually needs them. Furthermore there are tricks like this.SuspendLayout(); and this.ResumeLayout(); that can help improve loading time a little.
Our app has the same problem and we 'solved' it with NGen and postponing loading the comboboxes. Still on older machines loading time takes some time.
hope this helps...
I've found a living worth working for, but I haven't found work worth living for.
<marquee>
|
|
|
|
|
Thanks the SuspsendLayout() trick.
Thanks to a link on the microsoft newsgroup (where I also asked the question) I realized that... I should take some time to read NGEN documentation....
Some one else, still on MS newsgoup, suggested that just like Office or Adobe, I could have a "QuickStart" application, clever hey!
|
|
|
|
|
Super Lloyd wrote: Some one else, still on MS newsgoup, suggested that just like Office or Adobe, I could have a "QuickStart" application, clever hey!
If you do, give the user a choice about it at install time, and an easy way to change thier mind. I despise having to remove unwanted crap that starts itself everytime I boot my PC.
|
|
|
|
|
Of course!
|
|
|
|
|
how can use COM interop to communicate with Word
i want example to make search in word file ....
Palestine
|
|
|
|
|
This link[^] should give you a good starting point.
|
|
|
|
|
How do we find Eigen vector and Eigen values of an image in C#.net?
Vicky
|
|
|
|
|
1st transform the image into a matrix
2nd use some math library to get the eigen value/vector of the matrix
|
|
|
|
|
Hi all
I create a variable in Crystal report(formula editor) , for example :
numberVar MyNumber;
if MyNumber=10 then {TestReport.firstname} = {?myfirstname}
I want to use this variable(MyNumber)in Form1.cs(using c#.net).
How can do it , ? if not , what's the best way to passing this variable into the My Form.
Thanks
s_mostafa_h
|
|
|
|
|
Yes, there are actually several ways to get to Rome... Oh, you mean something else...you might want to read point 3 in the post "How to get an answer to you question" pinned as the first post in this forum.
|
|
|
|
|
if u are angry , it's better for u to rest and relax ... .
s_mostafa_h
|
|
|
|
|
I am not angry, just using sarcasm.
Basically there are two reasons to use a decent subject:
1) It increase the likelyhood of the people reading your question are actually the people able to answer it - instead of just a random selection.
2) The forum becomes useless if all subjets simply says "how do i...", "help with..." etc. This means less users and hence fewer answers.
So for your own sake - and for the rest of us - please do not write meaningless subjects.
|
|
|
|
|
ofcourse , u are right ,
but actually , I searched in anywhere to solving my problem .
in any case , if u are a developer , it's better to guide us for ur explaining .
Yours ,
s_mostafa_h
|
|
|
|
|
I am a developer, but I do not know Crystal Reports (and prefer to keep it that way). I did guide you by suggesting you post in a way so people with the required knowledge MIGHT look at your post.
|
|
|
|
|
it's better to forgot it ...
s_mostafa_h
|
|
|
|
|
Hi Friends
This is Sriram working as a Software Engg in Chennai.
I have a requirement that has to access the VSS database.
The functionality must do what ever can be done using VSS client such as Checking out a specific folder or file, Checking in or getting the latest version of a specific folder by the specified user.
All these operations have to be performed through my C# code.
Do any one of u have done such a process or have any idea about it or is there any DLL's available to accomplish this task.
Waiting for the replies
|
|
|
|
|
There is a COM interface as far as I remember. I have for example seen a web interface based on this.
|
|
|
|
|
|
Hi Friends
I have used SourceSafeTypeLib dll in Win32 folder to open a connection with VSS database and get the Latest of the file required.
But i am not aware of how to do the Check Out and Check in Process in using C#.
The code that i have used to Get the Latest version of the file is
IVSSDatabase m_DB;
string m_username;
ArrayList m_FileDetails = new ArrayList();
ArrayList m_UniqueFileDetails = new ArrayList();
string[] m_strPaths = new string[100];
int m_index = 0;
string result = Connect(@"C:\Documents and Settings\admin\My Documents\SampleDatabase\srcsafe.ini","pvs","pvs");
if(result=="Connected")
{
string result1 = GetLatest(@"$\Sample\Requirements\SRS",@"C:\Sample1\Requirements\SRS","pvs");
if(result1== "Completed")
{
MessageBox.Show("Successfully completed the task");
}
else if(result1 == "IVSSDatabase is null")
{
MessageBox.Show("Error while Getting the Latest");
}
}
else
{
MessageBox.Show("Cannot Establish Connection to Database Specified");
}
}
catch(Exception ex)
{
MessageBox.Show("Exception Raised");
MessageBox.Show(ex.ToString());
}
}
public string Connect(string databasePath, string username, string password)
{
m_DB = new VSSDatabaseClass();
try
{
m_DB.Open(databasePath,username,password);
}
catch(System.Runtime.InteropServices.COMException ex)
{
return ex.Message.ToString();
}
catch(Exception ex)
{
return ex.Message.ToString();
}
return "Connected";
}
public string GetLatest( string path, string localpath,string username )
{
m_username = username;
m_FileDetails.RemoveRange( 0, m_FileDetails.Count );
m_UniqueFileDetails.RemoveRange( 0, m_UniqueFileDetails.Count );
string strResult = "IVSSDatabase is null";
if( m_DB != null )
{
IVSSItem vitem = m_DB.get_VSSItem( path, false );
GetItems( path, localpath, vitem );
strResult = "Completed";
}
m_index = 0;
return strResult;
}
public void GetItems( string path, string localpath, IVSSItem item )
{
string temp = localpath;
if( item.Type == 1 ) // ignore if not project
{
}
else
{
IVSSItems ppItems;
ppItems = item.get_Items( false );
string strProj = item.Name;
foreach( IVSSItem childItem in ppItems )
{
localpath = temp;
string strUniquePath = localpath;
//m_index = 0;
string strname = childItem.Name;
string strPath = GetPaths( childItem );
string strC = strPath;
strC += "\\";
strC += strname;
localpath += strC;
string strLocalPath = localpath;
m_username = m_username.Replace(" ","");
strUniquePath += m_username;
strUniquePath += "\\";
strUniquePath += strC;
childItem.Get( ref strUniquePath, 0 ); // store as
// unique path
localpath = temp;
m_FileDetails.Add( strLocalPath );
m_UniqueFileDetails.Add( strUniquePath );
GetItems( path, localpath, childItem );
}
}
}
public string GetPaths( IVSSItem pItem )
{
string b;
string cStr = "";
IVSSItem pParent = pItem.Parent;
if( pParent != null )
{
b = pParent.Name;
if( b.Length > 0 )
{
cStr += b;
m_strPaths[m_index] = cStr;
m_index++;
GetPaths( pParent );
}
}
string strPath = "";
for( int i = m_index; i > 0; i -- )
{
strPath += "\\";
strPath += m_strPaths[ i - 1 ];
}
return strPath;
}
The above code snippet will get the latest from the VSS and creates the same folder structure as in VSS in a seperate path with user name added to the Folder Name in the Server itself from where the Files can be read and placed in the Clients machine. it works fine.
But i need to do a Check Out and Check in operation from VSS.
Do any of u aware of this operation using C#. Do post replies
Sriram
|
|
|
|