title: How Can I Manipulate a File Path as a String?
body: <p>I use splice() function in JavaScript.</p>
  
  <p>I couldn't find an equivalent method for ASP.NET. Is there any?</p>
  
  <p>If not, how can I insert or remove an index of an array in ASP.NET?</p>
  
  <p>I am trying to use the logic of this JavaScript code I've written once. Trying to do the same with ASP.NET, if that would help.</p>
  
  <pre><code>var imagePath = "/ImageFolder/Gallery/AnAlbum/image.jpg";
  var folders = imagePath.split("/");
  var imageFile = folders[folders.length - 1];
  folders.splice(folders.length - 1, 1);
  var newPath = folders.join("/");
  var newImageUrl = newPath + "/thumb/thumb_" + imageFile;
  return newImageUrl;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p><strong><em>What is Splice?</em></strong></p>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice" rel="nofollow">From</a>.</p>
  
  <blockquote>
    <p>array.splice(start, deleteCount[, item1[, item2[, ...]]])</p>
    
    <p>Parameters</p>
    
    <p>start </p>
    
    <p>Index at which to start changing the array. If greater than the
    length of the array, actual starting index will be set to the length
    of the array. If negative, will begin that many elements from the end.</p>
    
    <p>deleteCount </p>
    
    <p>An integer indicating the number of old array elements to
    remove. If deleteCount is 0, no elements are removed. In this case,
    you should specify at least one new element. If deleteCount is greater
    than the number of elements left in the array starting at start, then
    all of the elements through the end of the array will be deleted.</p>
    
    <p>itemN </p>
    
    <p>The element to add to the array. If you don't specify any
    elements, splice() will only remove elements from the array. </p>
    
    <p>Returns</p>
    
    <p>An array containing the deleted elements. If only one element is
    removed, an array of one element is returned. If no elements are
    removed, an empty array is returned.</p>
  </blockquote>
  
  <p><strong><em>Expected Output:</em></strong></p>
  
  <p><a href="http://fiddle.jshell.net/su84qagp/" rel="nofollow">Fiddle</a></p>
  
  <blockquote>
    <p>/ImageFolder/Gallery/AnAlbum/image.jpg </p>
    
    <p>/ImageFolder/Gallery/AnAlbum/thumb/thumb_image.jpg </p>
  </blockquote>