Pritish Deshmukh

Pritish Deshmukh

  • NA
  • 194
  • 192.5k

Select the specific part of the URL

Dec 10 2011 2:54 AM
Hi
My URI contains such below path
http://192.168.3.100/PACS3.2.0_DATA/Android_Images/1/1.2.840.114257.0.11796824240075870457700001003416408300001/DICOMDIR.dic//PACS3.2.0

  I just want the
http://192.168.3.100/PACS3.2.0_DATA/Android_Images/1/1.2.840.114257.0.11796824240075870457700001003416408300001/DICOMDIR.dic

this URL and splite the last //PACS3.2.0

how I can do this? also my code is as

Android.Net.Uri data = Implementation.Tag as Android.Net.Uri;
  // else
  if (data != null)
  {

  //Uri data = Intent.Data; 
  Scheme = "http"; // "http"
  AndroidLog.Information("scheme : " + Scheme);

  Host = data.Host; // "192.168.3.100"
  AndroidLog.Information("host : " + Host);
  BaseServerDirectory = string.Empty;
  for (int i = 0; i < data.PathSegments.Count - 2; i++)
  {
  var item = data.PathSegments[i];
  BaseServerDirectory += item + "/";
  }
  BaseServerDirectory = BaseServerDirectory.Remove(BaseServerDirectory.Length - 1);
  //BaseServerDirectory = string .Format ("{0}/{1}", Intent.Data.PathSegments[0],Intent.Data.PathSegments[1]);

  AndroidLog.Information(BaseServerDirectory);

  int segcount = data.PathSegments.Count;
  AndroidLog.Information("segcount : " + Convert.ToInt32(segcount));

  // string firstseg = Intent.Data.PathSegments[0];
  StringBuilder sb = new StringBuilder();

  foreach (var item in data.PathSegments)
  {
  sb.Append("/" + item);
  }
  AndroidLog.Information(sb.ToString());

  UriBuilder builder = new UriBuilder();
  builder.Host = Host;
  builder.Scheme = Scheme;
  builder.Path = sb.ToString();//string .Format ("{0}/{1}",BaseServerDirectory , sb.ToString());
  DicomDirUrl = builder.ToString();
  AndroidLog.Information(DicomDirUrl);
}














Answers (1)