if (File.Exists(fileName)) { File.Delete(fileName); using (FileStream fs = new FileStream(fileName, FileMode.Create)) { StreamResourceInfo resource = Application.GetResourceStream(new Uri("/xx;component/Resources/" + fileName, UriKind.Relative)); resource.Stream.CopyTo(fs); } }