I have this:
private List<string> _listaCommiter()
{
string s = string.Empty;
string _start = ConfigurationSettings.AppSettings["dir_inicio"];
List<string> lista = new List<string>();
List<string> tes = new List<string>();
string path = ConfigurationSettings.AppSettings["Caminho_Commiter"];
string[] arquivos = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
string texto = string.Empty;
foreach (var item in arquivos)
{
s = Path.GetFileNameWithoutExtension(item);
int _int = item.ToString().IndexOf(_start);
texto = item.ToString().Substring(_int, item.Length);
if (!item.Contains("TSNMVC"))
lista.Add(s);
}
return lista;
}
At the moment I put the text variable inside the foreach, it gives me this error:
Message = Index and length must refer to a location within the string. Parameter name: length
Below the entire error message
System.ArgumentOutOfRangeException was unhandled HResult = -2146233086 Message = Index and length should refer to a location within the string. Parameter name: length Source = mscorlib
ParamName = length StackTrace: in System.String.Substring (Int32 startIndex, Int32 length) in CreatingExtracting_ZIP.Form1._listCommiter () in c: \ Projects_Amil \ CreatingExtraining_ZIP \ CreatingExtraining_ZIP \ Form1.cs: line 211 in CreatingExtracting_ZIP.Form1.button1_Click (Object sender, EventArgs, and) in c: \ Projects_Amil \ CreatingExtracting_ZIP \ CreatingExtraining_ZIP \ Form1.cs: line 240 in System.Windows.Forms.Control.OnClick (EventArgs and) in System.Windows.Forms.Button.OnClick (EventArgs and) in System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent) in System.Windows.Forms.Control.WmMouseUp (Message & m, MouseButtons button, Int32 clicks) in System.Windows.Forms.Control.WndProc (Message & m) in System.Windows.Forms.ButtonBase.WndProc (Message & m) in System.Windows.Forms.Button.WndProc (Message & m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message & m) in System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m) in System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW (MSG & msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop (IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner (Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop (Int32 reason, ApplicationContext context) in System.Windows.Forms.Application.Run (Form mainForm) in CreatingExtracting_ZIP.Program.Main () in c: \ Projects_Amil \ CreatingExtraining_ZIP \ CreatingExtraining_ZIP \ Program.cs: line 19 in System.AppDomain._nExecuteAssembly (RuntimeAssembly assembly, String [] args) in System.AppDomain.ExecuteAssembly (String assemblyFile, Evidence assemblySecurity, String [] args) in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly () in System.Threading.ThreadHelper.ThreadStart_Context (Object state) in System.Threading.ExecutionContext.RunInternal (ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading.ExecutionContext.Run (ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading.ExecutionContext.Run (ExecutionContext executionContext, ContextCallback callback, Object state) in System.Threading.ThreadHelper.ThreadStart () InnerException: