我是VB.Net的新手。我正在尝试调试我的项目,但我收到一个警告:变量&csCryptoStream'在被赋值之前使用。在运行时
可能会导致空引用异常我该如何解决?
Private Sub EncryptOrDecryptFile(strInputFile As String, strOutputFile As String, bytKey As Byte(), bytIV As Byte(), Direction As crypt.CryptoAction)
' The following expression was wrapped in a checked-statement
Try
Me.fsInput = New FileStream(strInputFile, FileMode.Open, FileAccess.Read)
Me.fsOutput = New FileStream(strOutputFile, FileMode.OpenOrCreate, FileAccess.Write)
Me.fsOutput.SetLength(0L)
Dim bytBuffer As Byte() = New Byte(4096) {}
Dim lngBytesProcessed As Long = 0L
Dim lngFileLength As Long = Me.fsInput.Length
Dim cspRijndael As RijndaelManaged = New RijndaelManaged()
Me.pbStatus.Value = 0
Me.pbStatus.Maximum = 100
Dim csCryptoStream As CryptoStream
Select Case Direction
Case crypt.CryptoAction.ActionEncrypt
csCryptoStream = New CryptoStream(Me.fsOutput, cspRijndael.CreateEncryptor(bytKey, bytIV), CryptoStreamMode.Write)
Case crypt.CryptoAction.ActionDecrypt
csCryptoStream = New CryptoStream(Me.fsOutput, cspRijndael.CreateDecryptor(bytKey, bytIV), CryptoStreamMode.Write)
End Select
While lngBytesProcessed < lngFileLength
Dim intBytesInCurrentBlock As Integer = Me.fsInput.Read(bytBuffer, 0, 4096)
Warning ---> csCryptoStream.Write(bytBuffer, 0, intBytesInCurrentBlock)
' The following expression was wrapped in a unchecked-expression
lngBytesProcessed += CLng(intBytesInCurrentBlock)
' The following expression was wrapped in a unchecked-expression
Me.pbStatus.Value = CInt(Math.Round(CDec(lngBytesProcessed) / CDec(lngFileLength) * 100.0))
End While
答案 0 :(得分:0)
声明df=read.csv("https://dl.dropboxusercontent.com/u/6791606/Flagellum%20track%200012%20100fps%20-%20converted.csv",header=T)
start_x=c()
start_y=c()
slice_id=c()
angle=c()
for(i in 1:length(unique(df$Slice))) {
sl = df[df$Slice==unique(df$Slice)[i],]
slice_id = unique(df$Slice)[i]
start_x[i] = sl[1,2]
start_y[i] = sl[1,3]
angle[i] = -atan((sl[1,3]-tail(sl,1)[,3])/(sl[1,2]-tail(sl,1)[,2]))
}
gl_mean_x = mean(start_x)
gl_mean_y = mean(start_y)
gl_mean_angle = mean(angle)
df$X_center = df$X-gl_mean_x
df$Y_center = df$Y-gl_mean_y
## compute mean angle / create new score
alpha = gl_mean_angle
rotm <- matrix(c(cos(alpha),sin(alpha),-sin(alpha),cos(alpha)),ncol=2)
M = cbind(df$X_center,df$Y_center)
M2 <- t(rotm %*% (
t(M)-c(M[1,1],M[1,2])
)+c(M[1,1],M[1,2]))
df$X_center_angle = M2[,1]
df$Y_center_angle = M2[,2]
library(ggplot2)
ggplot(df, aes(x = X_center_angle, y = Y_center_angle)) +
geom_line(aes(color = factor(Slice))) +
stat_smooth(aes(color = factor(Slice)), se = FALSE)
如下:
CryptoStream
在 Dim csCryptoStream As CryptoStream = Nothing
Case Else
”条款
在使用此变量之前检查
Case/Select