문제

나는 WP7 개발에 새로운 예를 들어, 간단한 예를 사용하여 시도하고 있습니다 ..

이미지 제어가 있고 이미지를로드하고 이미지 제어에 표시하고 다른 하나는 이미지를 작성 해야하는 새 폴더에 해당 이미지를 저장하는 것입니다.

아래의 코드가 있고 오류가 발생하지 않지만 문제는 디렉토리를 만들고 해당 폴더에 존재한 이미지를 저장할 수 없습니다.

디렉토리를 저장 한 후 이미지뿐만 아니라 디렉토리를 볼 수 없습니다.

에뮬레이터 (또는)의 폴더를 Windows Phone에서 생성 된 디렉토리를 볼 수있는뿐만 아니라

Imports System.IO
Imports Microsoft.Phone.Tasks
Imports System.IO.IsolatedStorage
Imports System.Windows.Media.Imaging

Partial Public Class Page1
    Inherits PhoneApplicationPage

    Public Sub New()
        InitializeComponent()
        photoChooserTask = New PhotoChooserTask()
        AddHandler photoChooserTask.Completed, AddressOf photoChooserTask_Completed
    End Sub
    Dim photoChooserTask As PhotoChooserTask
    Private Sub photoChooserTask_Completed(sender As Object, e As PhotoResult)
        Dim bmp As System.Windows.Media.Imaging.BitmapImage = New System.Windows.Media.Imaging.BitmapImage()
        bmp.SetSource(e.ChosenPhoto)
        Image1.Source = bmp
        Dim originalFilename = Path.GetFileName(e.OriginalFileName)
        SaveImage(e.ChosenPhoto, originalFilename, 0, 100)

    End Sub
    Public Shared Sub SaveImage(ByVal imageStream As Stream, ByVal fileName As String, ByVal orientation As Integer, ByVal quality As Integer)
        Using isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()
            If isolatedStorage.FileExists("NewPics\fileName") Then
                isolatedStorage.DeleteFile("NewPics\fileName")
            End If

            If Not isolatedStorage.DirectoryExists("NewPics") Then
                isolatedStorage.CreateDirectory("NewPics")
            End If


            'isolatedStorage.CreateDirectory("NewPics")
            'Dim fileStream As New IsolatedStorageFileStream("fileName", FileMode.Create, isolatedStorage)
            Dim fileStream = isolatedStorage.CreateFile("NewPics\" + fileName)
            Dim bitmap = New BitmapImage()
            bitmap.SetSource(imageStream)

            Dim wb = New WriteableBitmap(bitmap)
            wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, orientation, quality)
            fileStream.Close()
        End Using
    End Sub
    Private Sub Button1_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Try
            photoChooserTask.Show()

        Catch ex As System.InvalidOperationException

            MessageBox.Show("An error occurred.")
        End Try
    End Sub
End Class
.

누구든지 내가 실수를 저지르는 곳에서 나에게 말할 수 있습니까?

도움이 되었습니까?

해결책

코드가 완벽합니다. 실버 라이트는 이름을 의미하는 파일을 저장하는 것과 같은 파일을 저장하기 위해 "격리 된 저장소"를 사용한다는 문제입니다.응용 프로그램에서 만든 파일이나 디렉토리는 응용 프로그램에서만 액세스 할 수 있습니다.

에뮬레이터가 다시 시작한 후에도 유지할 필요가 없으므로 에뮬레이터가 격리 된 저장소 파일을 메모리에 저장하는 것이라고 생각합니다.응용 프로그램의 고립 된 스토리지 내에서 쉽게 볼 수있는 경우 WP7 탐색기와 같은 도구를 사용할 수 있습니다. "nofollow"> http : //wp7explorer.codeplex.com /

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top